OSDN Git Service

avformat/utils/av_probe_input_buffer2: fix offset check
[android-x86/external-ffmpeg.git] / libavformat / utils.c
index 8854d5f..ef688a5 100644 (file)
@@ -370,9 +370,6 @@ int av_probe_input_buffer2(AVIOContext *pb, AVInputFormat **fmt,
     for(probe_size= PROBE_BUF_MIN; probe_size<=max_probe_size && !*fmt;
         probe_size = FFMIN(probe_size<<1, FFMAX(max_probe_size, probe_size+1))) {
 
-        if (probe_size < offset) {
-            continue;
-        }
         score = probe_size < max_probe_size ? AVPROBE_SCORE_RETRY : 0;
 
         /* read probe data */
@@ -388,6 +385,8 @@ int av_probe_input_buffer2(AVIOContext *pb, AVInputFormat **fmt,
             ret = 0;            /* error was end of file, nothing read */
         }
         buf_offset += ret;
+        if (buf_offset < offset)
+            continue;
         pd.buf_size = buf_offset - offset;
         pd.buf = &buf[offset];