Commit 05aa53dc authored by Paul B Mahol's avatar Paul B Mahol

avcodec/qdrw: fix decoding odd size images for 16bit case

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent f8d2079a
...@@ -199,26 +199,18 @@ static int decode_rle16(AVCodecContext *avctx, AVFrame *p, GetByteContext *gbc) ...@@ -199,26 +199,18 @@ static int decode_rle16(AVCodecContext *avctx, AVFrame *p, GetByteContext *gbc)
if (code & 0x80 ) { /* run */ if (code & 0x80 ) { /* run */
pix = bytestream2_get_be16(gbc); pix = bytestream2_get_be16(gbc);
for (j = 0; j < 257 - code; j++) { for (j = 0; j < 257 - code; j++) {
out[pos] = pix; if (pos < offset) {
pos++; out[pos++] = pix;
if (pos >= offset) {
pos -= offset;
pos++;
} }
if (pos >= offset)
return AVERROR_INVALIDDATA;
} }
left -= 3; left -= 3;
} else { /* copy */ } else { /* copy */
for (j = 0; j < code + 1; j++) { for (j = 0; j < code + 1; j++) {
out[pos] = bytestream2_get_be16(gbc); if (pos < offset) {
pos++; out[pos++] = bytestream2_get_be16(gbc);
if (pos >= offset) { } else {
pos -= offset; bytestream2_skip(gbc, 2);
pos++;
} }
if (pos >= offset)
return AVERROR_INVALIDDATA;
} }
left -= 1 + (code + 1) * 2; left -= 1 + (code + 1) * 2;
} }
......
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