libavformat/rtpenc_mpegts: check avformat_new_stream() return value

The function avformat_new_stream() returns a NULL pointer on failure.
However, in function rtp_mpegts_write_header(), its return value is not
validated before it is dereferenced. Check the return value against NULL
to avoid potential NULL dereference.

Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Pan Bian 2017-11-27 09:30:53 +08:00 committed by Michael Niedermayer
parent eb86f72fca
commit 5b4baf1506
1 changed files with 4 additions and 0 deletions

View File

@ -85,6 +85,10 @@ static int rtp_mpegts_write_header(AVFormatContext *s)
}
rtp_ctx->oformat = rtp_format;
st = avformat_new_stream(rtp_ctx, NULL);
if (!st) {
ret = AVERROR(ENOMEM);
goto fail;
}
st->time_base.num = 1;
st->time_base.den = 90000;
st->codecpar->codec_id = AV_CODEC_ID_MPEG2TS;