Commit d68fb147 authored by Derek Buitenhuis's avatar Derek Buitenhuis Committed by Anton Khirnov

mjpegdec: Properly fail on malloc failure

Signed-off-by: 's avatarDerek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: 's avatarAnton Khirnov <anton@khirnov.net>
parent 85ce9636
......@@ -1327,9 +1327,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')
......@@ -1351,7 +1353,6 @@ static int mjpeg_decode_com(MJpegDecodeContext *s)
av_free(cbuf);
}
}
return 0;
}
......@@ -1525,8 +1526,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;
}
if (!CONFIG_JPEGLS_DECODER &&
(start_code == SOF48 || start_code == LSE)) {
......
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