avcodec/libopenjpegenc: Check the return code of av_frame_ref()

Fixes CID1163842

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2014-01-24 02:58:20 +01:00
parent 7853024071
commit 52d2bcc786
1 changed files with 4 additions and 1 deletions

View 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];