summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPan Bian <[email protected]>2017-11-27 09:30:53 +0800
committerMichael Niedermayer <[email protected]>2017-11-28 01:18:22 +0100
commit5b4baf1506277863e9c1fa4bd302a4653e859669 (patch)
tree8e9be5bea8bfe622e9cc85b7636e2a9e9b29e1ab
parenteb86f72fcaf3abd6c7d243d7c85ab0440f752be5 (diff)
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 <[email protected]> Signed-off-by: Michael Niedermayer <[email protected]>
-rw-r--r--libavformat/rtpenc_mpegts.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libavformat/rtpenc_mpegts.c b/libavformat/rtpenc_mpegts.c
index 7af02e0d2f..5f81e1a145 100644
--- a/libavformat/rtpenc_mpegts.c
+++ b/libavformat/rtpenc_mpegts.c
@@ -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;