avcodec/libopenjpegenc: Check the return code of av_frame_ref()
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 24 Jan 2014 01:58:20 +0000 (02:58 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 24 Jan 2014 01:58:20 +0000 (02:58 +0100)
Fixes CID1163842

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/libopenjpegenc.c

index e056dd7..f113be3 100644 (file)
@@ -504,7 +504,10 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         gbrframe = av_frame_alloc();
         if (!gbrframe)
             return AVERROR(ENOMEM);
-        av_frame_ref(gbrframe, frame);
+        if ((ret = av_frame_ref(gbrframe, frame)) < 0) {
+            av_frame_free(&gbrframe);
+            return ret;
+        }
         gbrframe->data[0] = frame->data[2]; // swap to be rgb
         gbrframe->data[1] = frame->data[0];
         gbrframe->data[2] = frame->data[1];