Commit 2ab823d4 authored by Clément Bœsch's avatar Clément Bœsch

Merge commit 'd68fb147'

* commit 'd68fb147':
  mjpegdec: Properly fail on malloc failure
Merged-by: 's avatarClément Bœsch <u@pkh.me>
parents 63ac806c d68fb147
......@@ -1876,9 +1876,11 @@ static int mjpeg_decode_com(MJpegDecodeContext *s)
{
int len = get_bits(&s->gb, 16);
if (len >= 2 && 8 * len - 16 <= get_bits_left(&s->gb)) {
char *cbuf = av_malloc(len - 1);
if (cbuf) {
int i;
char *cbuf = av_malloc(len - 1);
if (!cbuf)
return AVERROR(ENOMEM);
for (i = 0; i < len - 2; i++)
cbuf[i] = get_bits(&s->gb, 8);
if (i > 0 && cbuf[i - 1] == '\n')
......@@ -1904,7 +1906,6 @@ static int mjpeg_decode_com(MJpegDecodeContext *s)
av_free(cbuf);
}
}
return 0;
}
......@@ -2114,8 +2115,11 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
else if (start_code >= APP0 && start_code <= APP15)
mjpeg_decode_app(s);
/* Comment */
else if (start_code == COM)
mjpeg_decode_com(s);
else if (start_code == COM) {
ret = mjpeg_decode_com(s);
if (ret < 0)
return ret;
}
ret = -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment