Mercurial > libavcodec.hg
changeset 9927:f954ea120c78 libavcodec
Reallocate internal buffer when coded frame size changes.
Fixes out-of-bounds reads and writes with i32/smclocki32.avi.1.0 from issue 1240.
author | reimar |
---|---|
date | Mon, 06 Jul 2009 16:48:23 +0000 |
parents | 773041579748 |
children | 16330a3b573b |
files | indeo3.c |
diffstat | 1 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/indeo3.c Mon Jul 06 16:45:12 2009 +0000 +++ b/indeo3.c Mon Jul 06 16:48:23 2009 +0000 @@ -107,6 +107,7 @@ unsigned int bufsize = luma_pixels * 2 + luma_width * 3 + (chroma_pixels + chroma_width) * 4; + av_freep(&s->buf); if(!(s->buf = av_malloc(bufsize))) return AVERROR(ENOMEM); s->iv_frame[0].y_w = s->iv_frame[1].y_w = luma_width; @@ -997,6 +998,17 @@ if(avcodec_check_dimensions(avctx, image_width, image_height)) return -1; + if (image_width != avctx->width || image_height != avctx->height) { + int ret; + avcodec_set_dimensions(avctx, image_width, image_height); + s->width = avctx->width; + s->height = avctx->height; + ret = iv_alloc_frames(s); + if (ret < 0) { + s->width = s->height = 0; + return ret; + } + } chroma_height = ((image_height >> 2) + 3) & 0x7ffc; chroma_width = ((image_width >> 2) + 3) & 0x7ffc;