h264: reset data_partitioning if decoding the slice header for NAL_DPA fails
authorAnton Khirnov <anton@khirnov.net>
Thu, 28 Nov 2013 09:54:35 +0000 (10:54 +0100)
committerReinhard Tartler <siretart@tauware.de>
Sun, 1 Jun 2014 00:05:18 +0000 (20:05 -0400)
If it was set before then we can end up trying to decode a slice without
a valid slice header, which can lead to invalid memory access.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC:libav-stable@libav.org

libavcodec/h264.c

index f021e59..886fc04 100644 (file)
@@ -4013,8 +4013,13 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
             hx->intra_gb_ptr=
             hx->inter_gb_ptr= NULL;
 
-            if ((err = decode_slice_header(hx, h)) < 0)
+            if ((err = decode_slice_header(hx, h)) < 0) {
+                /* make sure data_partitioning is cleared if it was set
+                 * before, so we don't try decoding a slice without a valid
+                 * slice header later */
+                s->data_partitioning = 0;
                 break;
+            }
 
             hx->s.data_partitioning = 1;