Commit b00fb157 authored by Paul B Mahol's avatar Paul B Mahol

avcodec/sgirledec: fix infinite loop in decode_sgirle8()

Fixes #2985.
Reported-by: 's avatarPiotr Bandurski <ami_stuff@o2.pl>
Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent 601eab2b
...@@ -82,6 +82,8 @@ static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst, const uint8_t *sr ...@@ -82,6 +82,8 @@ static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst, const uint8_t *sr
if (v > 0 && v < 0xC0) { if (v > 0 && v < 0xC0) {
do { do {
int length = FFMIN(v, width - x); int length = FFMIN(v, width - x);
if (length <= 0)
break;
memset(dst + y*linesize + x, RGB332_TO_BGR8(*src), length); memset(dst + y*linesize + x, RGB332_TO_BGR8(*src), length);
INC_XY(length); INC_XY(length);
v -= length; v -= length;
...@@ -91,7 +93,7 @@ static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst, const uint8_t *sr ...@@ -91,7 +93,7 @@ static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst, const uint8_t *sr
v -= 0xC0; v -= 0xC0;
do { do {
int length = FFMIN3(v, width - x, src_end - src); int length = FFMIN3(v, width - x, src_end - src);
if (src_end - src < length) if (src_end - src < length || length <= 0)
break; break;
memcpy_rgb332_to_bgr8(dst + y*linesize + x, src, length); memcpy_rgb332_to_bgr8(dst + y*linesize + x, src, length);
INC_XY(length); INC_XY(length);
......
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