avcodec/h264_slice: Make setup_finished check cover more cases
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 27 Jul 2016 16:22:41 +0000 (18:22 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 27 Jul 2016 17:29:55 +0000 (19:29 +0200)
libavcodec/h264_slice.c

index 1fe89c3..e1de971 100644 (file)
@@ -1560,12 +1560,15 @@ int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl,
     if (ret < 0)
         return ret;
 
+    if (sl->first_mb_addr == 0 || !h->current_slice) {
+        if (h->setup_finished) {
+            av_log(h->avctx, AV_LOG_ERROR, "Too many fields\n");
+            return AVERROR_INVALIDDATA;
+        }
+    }
+
     if (sl->first_mb_addr == 0) { // FIXME better field boundary detection
         if (h->current_slice) {
-            if (h->setup_finished) {
-                av_log(h->avctx, AV_LOG_ERROR, "Too many fields\n");
-                return AVERROR_INVALIDDATA;
-            }
             if (h->max_contexts > 1) {
                 if (!h->single_decode_warning) {
                     av_log(h->avctx, AV_LOG_WARNING, "Cannot decode multiple access units as slice threads\n");