aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/qdrw.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2017-02-27 11:49:59 +0100
committerPaul B Mahol <onemda@gmail.com>2017-02-27 11:49:59 +0100
commit1dcf91f2d360e266cd1c8349cc427d360f535918 (patch)
tree4fc34534354012b3f05922cc09750314cd9fd78d /libavcodec/qdrw.c
parentdc78696ea4b82b46e4c1a26e6bb1ebe0f4652101 (diff)
downloadffmpeg-1dcf91f2d360e266cd1c8349cc427d360f535918.tar.gz
avcodec/qdrw: fix decoding of odd sized images for 8bpp
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavcodec/qdrw.c')
-rw-r--r--libavcodec/qdrw.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/libavcodec/qdrw.c b/libavcodec/qdrw.c
index 11a06751ac..975e44013f 100644
--- a/libavcodec/qdrw.c
+++ b/libavcodec/qdrw.c
@@ -231,26 +231,24 @@ static int decode_rle(AVCodecContext *avctx, AVFrame *p, GetByteContext *gbc,
if (code & 0x80 ) { /* run */
pix = bytestream2_get_byte(gbc);
for (j = 0; j < 257 - code; j++) {
- out[pos] = pix;
+ if (pos < offset)
+ out[pos] = pix;
pos += step;
- if (pos >= offset) {
+ if (pos >= offset && step > 1) {
pos -= offset;
pos++;
}
- if (pos >= offset)
- return AVERROR_INVALIDDATA;
}
left -= 2;
} else { /* copy */
for (j = 0; j < code + 1; j++) {
- out[pos] = bytestream2_get_byte(gbc);
+ if (pos < offset)
+ out[pos] = bytestream2_get_byte(gbc);
pos += step;
- if (pos >= offset) {
+ if (pos >= offset && step > 1) {
pos -= offset;
pos++;
}
- if (pos >= offset)
- return AVERROR_INVALIDDATA;
}
left -= 2 + code;
}