[FFmpeg-cvslog] avcodec/qdrw: fix decoding of odd sized images for 8bpp

Paul B Mahol git at videolan.org
Mon Feb 27 12:57:14 EET 2017


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Feb 27 11:49:59 2017 +0100| [1dcf91f2d360e266cd1c8349cc427d360f535918] | committer: Paul B Mahol

avcodec/qdrw: fix decoding of odd sized images for 8bpp

Signed-off-by: Paul B Mahol <onemda at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1dcf91f2d360e266cd1c8349cc427d360f535918
---

 libavcodec/qdrw.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/libavcodec/qdrw.c b/libavcodec/qdrw.c
index 11a0675..975e440 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;
             }



More information about the ffmpeg-cvslog mailing list