avcodec/roqvideoenc: Check for av_malloc_array() failure
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 13 Jan 2015 14:14:27 +0000 (15:14 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 13 Jan 2015 14:14:27 +0000 (15:14 +0100)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/roqvideoenc.c

index 2f8e122a8ebff713b0277a8144ce8bab5e7ef542..731916f4d22624f0d006474e8a81a891be6f1443 100644 (file)
@@ -1042,6 +1042,12 @@ static av_cold int roq_encode_init(AVCodecContext *avctx)
     enc->last_motion8 =
         av_malloc_array ((enc->width*enc->height/64), sizeof(motion_vect));
 
+    if (!enc->tmpData || !enc->this_motion4 || !enc->last_motion4 ||
+        !enc->this_motion8 || !enc->last_motion8) {
+        roq_encode_end(avctx);
+        return AVERROR(ENOMEM);
+    }
+
     return 0;
 }