From c79cf0129edafc388ba1c47cd7b6a620557e48de Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 6 Aug 2014 18:19:57 +0100 Subject: [PATCH] error_concealment: avoid using the picture if not fully setup Fixes state becoming inconsistent and a null pointer dereference. CC: libav-stable@libav.org Bug-Id: CVE-2013-0860 Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Vittorio Giovara Signed-off-by: Anton Khirnov --- libavcodec/error_resilience.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c index 96f49c8adb..2735c6667d 100644 --- a/libavcodec/error_resilience.c +++ b/libavcodec/error_resilience.c @@ -900,6 +900,12 @@ void ff_er_frame_end(MpegEncContext *s) return; }; + if (s->picture_structure == PICT_FRAME && + s->current_picture.f.linesize[0] != s->current_picture_ptr->f.linesize[0]) { + av_log(s->avctx, AV_LOG_ERROR, "Error concealment not possible, frame not fully initialized\n"); + return; + } + if (s->current_picture.f.motion_val[0] == NULL) { av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n");