[FFmpeg-devel] [PATCH 5/7] lavc/libopenjpegenc: check av_frame_alloc() failure.

Michael Bradshaw mjbshaw at gmail.com
Sun Dec 29 18:47:12 CET 2013


On Sun, Dec 29, 2013 at 3:11 AM, Nicolas George <george at nsup.org> wrote:

> Signed-off-by: Nicolas George <george at nsup.org>
> ---
>  libavcodec/libopenjpegenc.c | 2 ++
>  1 file changed, 2 insertions(+)
>
>
> Completely untested (my vacation box is slow, I did not feel like
> rebuilding
> the whole project enabling libopenjpegenc just for that.
>
>
> diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
> index 0205c7d..e056dd7 100644
> --- a/libavcodec/libopenjpegenc.c
> +++ b/libavcodec/libopenjpegenc.c
> @@ -502,6 +502,8 @@ static int libopenjpeg_encode_frame(AVCodecContext
> *avctx, AVPacket *pkt,
>      case AV_PIX_FMT_GBRP14:
>      case AV_PIX_FMT_GBRP16:
>          gbrframe = av_frame_alloc();
> +        if (!gbrframe)
> +            return AVERROR(ENOMEM);
>          av_frame_ref(gbrframe, frame);
>          gbrframe->data[0] = frame->data[2]; // swap to be rgb
>          gbrframe->data[1] = frame->data[0];
>

LGTM


More information about the ffmpeg-devel mailing list