diff options
author | Micah F. Galizia <micahgalizia@gmail.com> | 2010-03-26 01:12:14 +0000 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-03-26 01:12:14 +0000 |
commit | 532aa889ebfea486c0d1898a8ed672e001a30598 (patch) | |
tree | ef5d41127d0d3175f9baf5453e604691d5d205ff /libavformat/utils.c | |
parent | fd12dd959305aa80bd2e434cc087f3cabd013242 (diff) | |
download | ffmpeg-532aa889ebfea486c0d1898a8ed672e001a30598.tar.gz |
Fix updating condition for the probe_size variable in the internal
loop of ff_probe_input_buffer(), making sure that probe_size is always
set to probe_max_size in the last iteration.
Also make the function return an error if we get to the max probe
length and still cannot figure out what the format is.
Patch by Micah Galizia micahgalizia A gmail D com.
Originally committed as revision 22688 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/utils.c')
-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 2c06e66666..b29e65d93c 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -478,7 +478,8 @@ int ff_probe_input_buffer(ByteIOContext **pb, AVInputFormat **fmt, return AVERROR(EINVAL); } - for(probe_size= PROBE_BUF_MIN; probe_size<=max_probe_size && !*fmt && ret >= 0; probe_size<<=1){ + for(probe_size= PROBE_BUF_MIN; probe_size<=max_probe_size && !*fmt && ret >= 0; + probe_size = FFMIN(probe_size<<1, FFMAX(max_probe_size, probe_size+1))) { int ret, score = probe_size < max_probe_size ? AVPROBE_SCORE_MAX/4 : 0; int buf_offset = (probe_size == PROBE_BUF_MIN) ? 0 : probe_size>>1; @@ -513,6 +514,11 @@ int ff_probe_input_buffer(ByteIOContext **pb, AVInputFormat **fmt, } av_free(buf); + + if (!*fmt) { + return AVERROR_INVALIDDATA; + } + if (url_fseek(*pb, 0, SEEK_SET) < 0) { url_fclose(*pb); if (url_fopen(pb, filename, URL_RDONLY) < 0) |