diff mbox

[FFmpeg-devel] avcodec/h264_slice: Make setup_finished check cover more cases

Message ID 1469637437-9608-1-git-send-email-michael@niedermayer.cc
State Accepted
Commit 8385e1718ee1fed107ec911d0b17fed3f7d74c71
Headers show

Commit Message

Michael Niedermayer July 27, 2016, 4:37 p.m. UTC
---
 libavcodec/h264_slice.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Michael Niedermayer July 27, 2016, 5:34 p.m. UTC | #1
On Wed, Jul 27, 2016 at 06:37:17PM +0200, Michael Niedermayer wrote:
> ---
>  libavcodec/h264_slice.c |   11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)

as ubitux merge work benefits from this applied

thx

[...]
diff mbox

Patch

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 74e8118..8d20028 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1563,12 +1563,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");