Commit e07ac727 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/g2meet: Fix framebuf size

Currently the code can in some cases draw tiles that hang outside the
allocated buffer. This patch increases the buffer size to avoid out
of array accesses. An alternative would be to fail if such tiles are
encountered.
I do not know if any valid files use such hanging tiles.

Fixes Ticket2971
Found-by: ami_stuff
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 5dca837a
...@@ -443,8 +443,8 @@ static int g2m_init_buffers(G2MContext *c) ...@@ -443,8 +443,8 @@ static int g2m_init_buffers(G2MContext *c)
int aligned_height; int aligned_height;
if (!c->framebuf || c->old_width < c->width || c->old_height < c->height) { if (!c->framebuf || c->old_width < c->width || c->old_height < c->height) {
c->framebuf_stride = FFALIGN(c->width * 3, 16); c->framebuf_stride = FFALIGN(c->width + 15, 16) * 3;
aligned_height = FFALIGN(c->height, 16); aligned_height = c->height + 15;
av_free(c->framebuf); av_free(c->framebuf);
c->framebuf = av_mallocz(c->framebuf_stride * aligned_height); c->framebuf = av_mallocz(c->framebuf_stride * aligned_height);
if (!c->framebuf) if (!c->framebuf)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment