From b88ba823153f3a2f5587c439404d66fdbfc68339 Mon Sep 17 00:00:00 2001 From: Mark Hills Date: Wed, 26 Mar 2003 10:30:08 +0000 Subject: [PATCH] ffserver deallocate ctx->streams on closing patch by (Mark Hills ) Originally committed as revision 1704 to svn://svn.ffmpeg.org/ffmpeg/trunk --- ffserver.c | 6 +++++- libavformat/aviobuf.c | 9 +++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ffserver.c b/ffserver.c index 73e61e5a53..173ae8457b 100644 --- a/ffserver.c +++ b/ffserver.c @@ -744,8 +744,12 @@ static void close_connection(HTTPContext *c) } } + ctx = &c->fmt_ctx; + + for(i=0; inb_streams; i++) + av_free(ctx->streams[i]) ; + if (!c->last_packet_sent) { - ctx = &c->fmt_ctx; if (ctx->oformat) { /* prepare header */ if (url_open_dyn_buf(&ctx->pb) >= 0) { diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index fc1ae2c64f..11d00f239d 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -569,12 +569,9 @@ static void dyn_buf_write(void *opaque, uint8_t *buf, int buf_size) } if (new_allocated_size > d->allocated_size) { - new_buffer = av_malloc(new_allocated_size); - if (!new_buffer) - return; - memcpy(new_buffer, d->buffer, d->size); - av_free(d->buffer); - d->buffer = new_buffer; + d->buffer = av_realloc(d->buffer, new_allocated_size); + if(d->buffer == NULL) + return ; d->allocated_size = new_allocated_size; } memcpy(d->buffer + d->pos, buf, buf_size);