]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/mpeg4videoenc: Check extradata malloc()
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 19 Mar 2021 15:30:08 +0000 (16:30 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 19 Mar 2021 23:36:09 +0000 (00:36 +0100)
Fixes: Null pointer dereference
Fixes: any mpeg4 testcase which fails the malloc at that exact spot
Found-by: Rafael Dutra <rafael.dutra@cispa.de>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/mpeg4videoenc.c

index a092ab01d08a998c3ca7d2bdb235516be2a021c6..a879d2fd188805343a5341212d54596bf7c44f85 100644 (file)
@@ -1304,6 +1304,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
 
     if (s->avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
         s->avctx->extradata = av_malloc(1024);
+        if (!s->avctx->extradata)
+            return AVERROR(ENOMEM);
         init_put_bits(&s->pb, s->avctx->extradata, 1024);
 
         if (!(s->workaround_bugs & FF_BUG_MS))