h263dec: Prevent dimension changes from leaking on errors in header parsing.
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 18 Apr 2012 19:03:03 +0000 (21:03 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 18 Apr 2012 19:21:28 +0000 (21:21 +0200)
This fixes crashes with frame threads caused by inconsistent context parameters.

Fixes Ticket1207

Found-by: John Villamil
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/h263dec.c

index 8669d14..50699c7 100644 (file)
@@ -438,6 +438,14 @@ retry:
         ret = ff_h263_decode_picture_header(s);
     }
 
+    if (HAVE_THREADS && (s->avctx->active_thread_type&FF_THREAD_FRAME) && ret < 0) {
+        if (   s->width  != avctx->coded_width
+            || s->height != avctx->coded_height) {
+                av_log(s->avctx, AV_LOG_WARNING, "Reverting picture dimensions change due to header decoding failure\n");
+                s->width = avctx->coded_width;
+                s->height= avctx->coded_height;
+        }
+    }
     if(ret==FRAME_SKIPPED) return get_consumed_bytes(s, buf_size);
 
     /* skip if the header was thrashed */