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>
This commit is contained in:
13
ffserver.c
13
ffserver.c
@@ -3331,6 +3331,7 @@ static int rtp_new_av_stream(HTTPContext *c,
|
|||||||
URLContext *h = NULL;
|
URLContext *h = NULL;
|
||||||
uint8_t *dummy_buf;
|
uint8_t *dummy_buf;
|
||||||
int max_packet_size;
|
int max_packet_size;
|
||||||
|
void *st_internal;
|
||||||
|
|
||||||
/* now we can open the relevant output stream */
|
/* now we can open the relevant output stream */
|
||||||
ctx = avformat_alloc_context();
|
ctx = avformat_alloc_context();
|
||||||
@@ -3338,14 +3339,13 @@ static int rtp_new_av_stream(HTTPContext *c,
|
|||||||
return -1;
|
return -1;
|
||||||
ctx->oformat = av_guess_format("rtp", NULL, NULL);
|
ctx->oformat = av_guess_format("rtp", NULL, NULL);
|
||||||
|
|
||||||
st = av_mallocz(sizeof(AVStream));
|
st = avformat_new_stream(ctx, NULL);
|
||||||
if (!st)
|
if (!st)
|
||||||
goto fail;
|
goto fail;
|
||||||
ctx->nb_streams = 1;
|
|
||||||
ctx->streams = av_mallocz_array(ctx->nb_streams, sizeof(AVStream *));
|
av_freep(&st->codec);
|
||||||
if (!ctx->streams)
|
av_freep(&st->info);
|
||||||
goto fail;
|
st_internal = st->internal;
|
||||||
ctx->streams[0] = st;
|
|
||||||
|
|
||||||
if (!c->stream->feed ||
|
if (!c->stream->feed ||
|
||||||
c->stream->feed == c->stream)
|
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]],
|
c->stream->feed->streams[c->stream->feed_streams[stream_index]],
|
||||||
sizeof(AVStream));
|
sizeof(AVStream));
|
||||||
st->priv_data = NULL;
|
st->priv_data = NULL;
|
||||||
|
st->internal = st_internal;
|
||||||
|
|
||||||
/* build destination RTP address */
|
/* build destination RTP address */
|
||||||
ipaddr = inet_ntoa(dest_addr->sin_addr);
|
ipaddr = inet_ntoa(dest_addr->sin_addr);
|
||||||
|
Reference in New Issue
Block a user