diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-07-26 01:05:01 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-07-26 01:10:55 +0200 |
commit | 9054f6b66b3883d615177c738cb69c6337c4375c (patch) | |
tree | 8ad4e0b069fb91f3cb8182fb6fbb0493bf12e234 | |
parent | 6bf87785e8e92da4d2223741a3d7d13428cbae8b (diff) | |
download | ffmpeg-9054f6b66b3883d615177c738cb69c6337c4375c.tar.gz |
probe_codec: fix memory corruption
Found-by: Tanami Ohad
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/utils.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index caa8c4b528..fa3b962954 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -680,11 +680,15 @@ static void probe_codec(AVFormatContext *s, AVStream *st, const AVPacket *pkt) --st->probe_packets; if (pkt) { - pd->buf = av_realloc(pd->buf, pd->buf_size+pkt->size+AVPROBE_PADDING_SIZE); + uint8_t *new_buf = av_realloc(pd->buf, pd->buf_size+pkt->size+AVPROBE_PADDING_SIZE); + if(!new_buf) + goto no_packet; + pd->buf = new_buf; memcpy(pd->buf+pd->buf_size, pkt->data, pkt->size); pd->buf_size += pkt->size; memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE); } else { +no_packet: st->probe_packets = 0; } |