From ee3c3dd523623e0d9e69aa2ce268fef82b201458 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <michaelni@gmx.at> Date: Mon, 11 Mar 2013 21:29:14 +0100 Subject: [PATCH] ff_alloc_picture: free tables in case of dimension mismatches Fixes memory corruption In theory this should not be needed but its better to check at one place than to hope 50 other places set the flags correctly --- libavcodec/mpegvideo.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 9fe93bf4abe..d0c8262fdeb 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -411,6 +411,11 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared) { int i, ret; + if (pic->qscale_table_buf) + if (pic->mbskip_table_buf->size < s->mb_stride * s->mb_height + 2 || + pic->qscale_table_buf->size < s->mb_stride * (s->mb_height + 1) + 1 + s->mb_stride) + free_picture_tables(pic); + if (shared) { assert(pic->f.data[0]); pic->shared = 1; -- GitLab