diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2015-11-11 21:04:01 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2015-11-11 21:26:50 +0100 |
commit | 2ec18db75cff03a5cfa0a0f28f22da6866f720d1 (patch) | |
tree | 231f74762a64d051ab146477e9695b9f9973bee3 /ffserver.c | |
parent | 351e625d60165be67c362af6e96ead6c9262623f (diff) | |
download | ffmpeg-2ec18db75cff03a5cfa0a0f28f22da6866f720d1.tar.gz |
ffserver: Replace one malloc(AVStream) by avformat_new_stream()
This fixes a null pointer dereference from the recently introduced
AVStream->internal
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'ffserver.c')
-rw-r--r-- | ffserver.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/ffserver.c b/ffserver.c index a32ba08c13..fb8ab7d3e7 100644 --- a/ffserver.c +++ b/ffserver.c @@ -3331,6 +3331,7 @@ static int rtp_new_av_stream(HTTPContext *c, URLContext *h = NULL; uint8_t *dummy_buf; int max_packet_size; + void *st_internal; /* now we can open the relevant output stream */ ctx = avformat_alloc_context(); @@ -3338,14 +3339,13 @@ static int rtp_new_av_stream(HTTPContext *c, return -1; ctx->oformat = av_guess_format("rtp", NULL, NULL); - st = av_mallocz(sizeof(AVStream)); + st = avformat_new_stream(ctx, NULL); if (!st) goto fail; - ctx->nb_streams = 1; - ctx->streams = av_mallocz_array(ctx->nb_streams, sizeof(AVStream *)); - if (!ctx->streams) - goto fail; - ctx->streams[0] = st; + + av_freep(&st->codec); + av_freep(&st->info); + st_internal = st->internal; if (!c->stream->feed || c->stream->feed == c->stream) @@ -3355,6 +3355,7 @@ static int rtp_new_av_stream(HTTPContext *c, c->stream->feed->streams[c->stream->feed_streams[stream_index]], sizeof(AVStream)); st->priv_data = NULL; + st->internal = st_internal; /* build destination RTP address */ ipaddr = inet_ntoa(dest_addr->sin_addr); |