summaryrefslogtreecommitdiff
path: root/libavcodec/mpegvideo.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-03-11 21:29:14 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-03-12 03:23:55 +0100
commitee3c3dd523623e0d9e69aa2ce268fef82b201458 (patch)
tree2911df6d519be9ec7a1a16cb9b66c8faef7cfc1f /libavcodec/mpegvideo.c
parent9e73f6d1f9a242ea0b2fdb3bf22890d2a4422be0 (diff)
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
Diffstat (limited to 'libavcodec/mpegvideo.c')
-rw-r--r--libavcodec/mpegvideo.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 9fe93bf4ab..d0c8262fde 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;