summaryrefslogtreecommitdiff
path: root/libavcodec/qdrw.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2017-02-27 11:24:43 +0100
committerPaul B Mahol <onemda@gmail.com>2017-02-27 11:24:43 +0100
commit05aa53dc553a9f824d81d7eaa0eb16b978264276 (patch)
tree6def394ff119d103890008f63bbf32bbdd3b2617 /libavcodec/qdrw.c
parentf8d2079a67865771097938ddfed5972c453ad603 (diff)
avcodec/qdrw: fix decoding odd size images for 16bit case
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavcodec/qdrw.c')
-rw-r--r--libavcodec/qdrw.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/libavcodec/qdrw.c b/libavcodec/qdrw.c
index e650f49547..e09872bf3e 100644
--- a/libavcodec/qdrw.c
+++ b/libavcodec/qdrw.c
@@ -199,26 +199,18 @@ static int decode_rle16(AVCodecContext *avctx, AVFrame *p, GetByteContext *gbc)
if (code & 0x80 ) { /* run */
pix = bytestream2_get_be16(gbc);
for (j = 0; j < 257 - code; j++) {
- out[pos] = pix;
- pos++;
- if (pos >= offset) {
- pos -= offset;
- pos++;
+ if (pos < offset) {
+ out[pos++] = pix;
}
- if (pos >= offset)
- return AVERROR_INVALIDDATA;
}
left -= 3;
} else { /* copy */
for (j = 0; j < code + 1; j++) {
- out[pos] = bytestream2_get_be16(gbc);
- pos++;
- if (pos >= offset) {
- pos -= offset;
- pos++;
+ if (pos < offset) {
+ out[pos++] = bytestream2_get_be16(gbc);
+ } else {
+ bytestream2_skip(gbc, 2);
}
- if (pos >= offset)
- return AVERROR_INVALIDDATA;
}
left -= 1 + (code + 1) * 2;
}