Merge commit 'be373cb50d3c411366fec7eef2eb3681abe48f96'
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 13 Jun 2013 11:56:14 +0000 (13:56 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 13 Jun 2013 11:57:07 +0000 (13:57 +0200)
* commit 'be373cb50d3c411366fec7eef2eb3681abe48f96':
  4xm: do not overread the prestream buffer

Conflicts:
libavcodec/4xm.c

See: 9c661e95
Merged-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/4xm.c

index 6a2476dcfdb857b8fd9dfb454069a8fd4bcf1c55..bb380f677929594dac0a3b656735ef1d7fd3d9e5 100644 (file)
@@ -603,7 +603,8 @@ static int decode_i_mb(FourXContext *f)
 }
 
 static const uint8_t *read_huffman_tables(FourXContext *f,
-                                          const uint8_t * const buf, int buf_size)
+                                          const uint8_t * const buf,
+                                          int buf_size)
 {
     int frequency[512] = { 0 };
     uint8_t flag[512];
@@ -626,6 +627,7 @@ static const uint8_t *read_huffman_tables(FourXContext *f,
             av_log(f->avctx, AV_LOG_ERROR, "invalid data in read_huffman_tables\n");
             return NULL;
         }
+
         for (i = start; i <= end; i++)
             frequency[i] = *ptr++;
         start = *ptr++;
@@ -779,7 +781,7 @@ static int decode_i_frame(FourXContext *f, AVFrame *frame, const uint8_t *buf, i
         return AVERROR_INVALIDDATA;
     }
 
-    prestream = read_huffman_tables(f, prestream, buf + length - prestream);
+    prestream = read_huffman_tables(f, prestream, prestream_size);
     if (!prestream) {
         av_log(f->avctx, AV_LOG_ERROR, "Error reading Huffman tables.\n");
         return AVERROR_INVALIDDATA;