adpcm-thp: fix invalid array indexing
authorMans Rullgard <mans@mansr.com>
Sun, 29 Apr 2012 00:17:37 +0000 (01:17 +0100)
committerMans Rullgard <mans@mansr.com>
Mon, 30 Apr 2012 23:21:30 +0000 (00:21 +0100)
Indexing outside array limits is invalid and breaks with gcc 4.8.

Signed-off-by: Mans Rullgard <mans@mansr.com>
libavcodec/adpcm.c

index 41d0d98..8170e7f 100644 (file)
@@ -1209,12 +1209,14 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
         int prev[2][2];
         int ch;
 
-        for (i = 0; i < 32; i++)
-            table[0][i] = sign_extend(bytestream2_get_be16u(&gb), 16);
+        for (i = 0; i < 2; i++)
+            for (n = 0; n < 16; n++)
+                table[i][n] = sign_extend(bytestream2_get_be16u(&gb), 16);
 
         /* Initialize the previous sample.  */
-        for (i = 0; i < 4; i++)
-            prev[0][i] = sign_extend(bytestream2_get_be16u(&gb), 16);
+        for (i = 0; i < 2; i++)
+            for (n = 0; n < 2; n++)
+                prev[i][n] = sign_extend(bytestream2_get_be16u(&gb), 16);
 
         for (ch = 0; ch <= st; ch++) {
             samples = (short *)c->frame.data[0] + ch;