diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-08-27 21:24:13 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-09-07 15:11:55 +0200 |
commit | aedef891fc81e22685ad0bed97f50095429fc671 (patch) | |
tree | 9d6d56ecb3d0a8ee73b7744477ead9e63db56be4 | |
parent | 958f0a0f19c76267e662192707b3bddd67f15770 (diff) | |
download | ffmpeg-aedef891fc81e22685ad0bed97f50095429fc671.tar.gz |
Fix memory corruption in case of memory allocation failure in av_probe_input_buffer()
Reported-by: Tanami Ohad
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 941bb552c6e08b40eb7d7842df19285cd650edd0)
-rw-r--r-- | libavformat/utils.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 8dd76f3e25..1a50c8cab9 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -596,13 +596,19 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, probe_size = FFMIN(probe_size<<1, FFMAX(max_probe_size, probe_size+1))) { int score = probe_size < max_probe_size ? AVPROBE_SCORE_MAX/4 : 0; int buf_offset = (probe_size == PROBE_BUF_MIN) ? 0 : probe_size>>1; + void *buftmp; if (probe_size < offset) { continue; } /* read probe data */ - buf = av_realloc(buf, probe_size + AVPROBE_PADDING_SIZE); + buftmp = av_realloc(buf, probe_size + AVPROBE_PADDING_SIZE); + if(!buftmp){ + av_free(buf); + return AVERROR(ENOMEM); + } + buf=buftmp; if ((ret = avio_read(pb, buf + buf_offset, probe_size - buf_offset)) < 0) { /* fail if error was not end of file, otherwise, lower score */ if (ret != AVERROR_EOF) { |