Merge remote-tracking branch 'qatar/master'
[ffmpeg.git] / libavcodec / h264.c
index 997818862085d1d1485fc1ab30d0b09f9779c0ee..f6fcc84eaa14ff73e298073c77f0daa24f0c3552 100644 (file)
@@ -3803,7 +3803,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
         int err;
 
         if(buf_index >= next_avc) {
-            if(buf_index >= buf_size) break;
+            if (buf_index >= buf_size - h->nal_length_size) break;
             nalsize = 0;
             for(i = 0; i < h->nal_length_size; i++)
                 nalsize = (nalsize << 8) | buf[buf_index++];