Commit 2a3720bc authored by Michael Niedermayer's avatar Michael Niedermayer

avformat/swfdec: Move packet size check before side data allocation

Fixes memleak
Fixes: 9eb9cf5b8c26dd0fa7107ed0348dcc1f/signal_sigabrt_7ffff6ae7c37_8927_f14c2a6ae1ad0bbde2c94f1da50e7074.swf

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 23720764
......@@ -395,6 +395,11 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->pos = pos;
pkt->stream_index = st->index;
if (linesize * height > pkt->size) {
res = AVERROR_INVALIDDATA;
goto bitmap_end;
}
switch (bmp_fmt) {
case 3:
pix_fmt = AV_PIX_FMT_PAL8;
......@@ -422,10 +427,6 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
} else
st->codecpar->format = pix_fmt;
if (linesize * height > pkt->size) {
res = AVERROR_INVALIDDATA;
goto bitmap_end;
}
memcpy(pkt->data, buf + colormapsize*colormapbpp, linesize * height);
res = pkt->size;
......
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