avcodec/iff: check if there is enough bytes left
authorPaul B Mahol <onemda@gmail.com>
Mon, 16 May 2016 13:37:24 +0000 (15:37 +0200)
committerPaul B Mahol <onemda@gmail.com>
Mon, 16 May 2016 13:39:28 +0000 (15:39 +0200)
Signed-off-by: Paul B Mahol <onemda@gmail.com>
libavcodec/iff.c

index eef7ce1..85fae15 100644 (file)
@@ -850,6 +850,9 @@ static void decode_delta_j(uint8_t *dst,
             for (g = 0; g < groups; g++) {
                 offset = bytestream2_get_be16(&gb);
 
+                if (bytestream2_get_bytes_left(&gb) < 1)
+                    return;
+
                 if (kludge_j)
                     offset = ((offset / (320 / 8)) * pitch) + (offset % (320 / 8)) - kludge_j;
                 else
@@ -893,6 +896,9 @@ static void decode_delta_j(uint8_t *dst,
                     for (d = 0; d < bpp; d++) {
                         unsigned noffset = offset + (r * pitch) + d * planepitch;
 
+                        if (bytestream2_get_bytes_left(&gb) < 1)
+                            return;
+
                         for (b = 0; b < bytes; b++) {
                             uint8_t value = bytestream2_get_byte(&gb);