Skip to content
Snippets Groups Projects
Commit bd12aa2b authored by Michael Niedermayer's avatar Michael Niedermayer
Browse files

avcodec/ljpegenc: Check for av_malloc_array() failure

parent d56b0984
No related branches found
No related tags found
No related merge requests found
...@@ -293,6 +293,8 @@ static av_cold int ljpeg_encode_init(AVCodecContext *avctx) ...@@ -293,6 +293,8 @@ static av_cold int ljpeg_encode_init(AVCodecContext *avctx)
avctx->coded_frame->key_frame = 1; avctx->coded_frame->key_frame = 1;
s->scratch = av_malloc_array(avctx->width + 1, sizeof(*s->scratch)); s->scratch = av_malloc_array(avctx->width + 1, sizeof(*s->scratch));
if (!s->scratch)
goto fail;
ff_idctdsp_init(&s->idsp, avctx); ff_idctdsp_init(&s->idsp, avctx);
ff_init_scantable(s->idsp.idct_permutation, &s->scantable, ff_init_scantable(s->idsp.idct_permutation, &s->scantable,
...@@ -310,6 +312,9 @@ static av_cold int ljpeg_encode_init(AVCodecContext *avctx) ...@@ -310,6 +312,9 @@ static av_cold int ljpeg_encode_init(AVCodecContext *avctx)
avpriv_mjpeg_val_dc); avpriv_mjpeg_val_dc);
return 0; return 0;
fail:
ljpeg_encode_close(avctx);
return AVERROR(ENOMEM);
} }
AVCodec ff_ljpeg_encoder = { AVCodec ff_ljpeg_encoder = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment