aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Aimar <fenrir@videolan.org>2011-09-11 18:51:52 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-09-21 18:02:34 +0200
commit8511c141e02d5a8c63d9cf1e8aef1d1135a7f7fa (patch)
tree9630d76c94fb071ee3853c75560dc47815730921
parent2bf9a09a2c10bacca1cc05950aa79030e7b68fa4 (diff)
downloadffmpeg-8511c141e02d5a8c63d9cf1e8aef1d1135a7f7fa.tar.gz
Fixed segfault on corrupted smacker streams in the demuxer.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit d0121e8d969cde74fa7dbd96d3602109b051e701)
-rw-r--r--libavformat/smacker.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libavformat/smacker.c b/libavformat/smacker.c
index 29a66e79fa..c22f6daa73 100644
--- a/libavformat/smacker.c
+++ b/libavformat/smacker.c
@@ -291,6 +291,10 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
frame_size -= 4;
smk->curstream++;
smk->bufs[smk->curstream] = av_realloc(smk->bufs[smk->curstream], size);
+ if (!smk->bufs[smk->curstream]) {
+ smk->buf_sizes[smk->curstream] = 0;
+ return AVERROR(ENOMEM);
+ }
smk->buf_sizes[smk->curstream] = size;
ret = avio_read(s->pb, smk->bufs[smk->curstream], size);
if(ret != size)
@@ -299,7 +303,9 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
}
flags >>= 1;
}
- if (av_new_packet(pkt, frame_size + 768))
+ if (frame_size < 0)
+ return AVERROR_INVALIDDATA;
+ if (av_new_packet(pkt, frame_size + 769))
return AVERROR(ENOMEM);
if(smk->frm_size[smk->cur_frame] & 1)
palchange |= 2;