avcodec/qdrw: fix decoding of odd sized images for 8bpp
Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
@@ -231,26 +231,24 @@ static int decode_rle(AVCodecContext *avctx, AVFrame *p, GetByteContext *gbc,
|
|||||||
if (code & 0x80 ) { /* run */
|
if (code & 0x80 ) { /* run */
|
||||||
pix = bytestream2_get_byte(gbc);
|
pix = bytestream2_get_byte(gbc);
|
||||||
for (j = 0; j < 257 - code; j++) {
|
for (j = 0; j < 257 - code; j++) {
|
||||||
|
if (pos < offset)
|
||||||
out[pos] = pix;
|
out[pos] = pix;
|
||||||
pos += step;
|
pos += step;
|
||||||
if (pos >= offset) {
|
if (pos >= offset && step > 1) {
|
||||||
pos -= offset;
|
pos -= offset;
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
if (pos >= offset)
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
}
|
||||||
left -= 2;
|
left -= 2;
|
||||||
} else { /* copy */
|
} else { /* copy */
|
||||||
for (j = 0; j < code + 1; j++) {
|
for (j = 0; j < code + 1; j++) {
|
||||||
|
if (pos < offset)
|
||||||
out[pos] = bytestream2_get_byte(gbc);
|
out[pos] = bytestream2_get_byte(gbc);
|
||||||
pos += step;
|
pos += step;
|
||||||
if (pos >= offset) {
|
if (pos >= offset && step > 1) {
|
||||||
pos -= offset;
|
pos -= offset;
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
if (pos >= offset)
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
}
|
||||||
left -= 2 + code;
|
left -= 2 + code;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user