X-Git-Url: https://git.videolan.org/?p=ffmpeg.git;a=blobdiff_plain;f=libavformat%2Futils.c;h=a4218db8edf7b576bfa542d720ac7e345ed7d26b;hp=d59a02d951e66220f64f997bff1bb101a8fa2c9f;hb=6cd650dbd2bea006e1c4b70456f6d9eb7f638922;hpb=695a766bff4cd8414a84e58159506d72b4e44892 diff --git a/libavformat/utils.c b/libavformat/utils.c index d59a02d951..a4218db8ed 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1863,10 +1863,10 @@ int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, filesize = avio_size(s->pb); pos_max = filesize - 1; do{ - pos_max -= step; + pos_max = FFMAX(0, pos_max - step); ts_max = ff_read_timestamp(s, stream_index, &pos_max, pos_max + step, read_timestamp); step += step; - }while(ts_max == AV_NOPTS_VALUE && pos_max >= step); + }while(ts_max == AV_NOPTS_VALUE && pos_max > 0); if (ts_max == AV_NOPTS_VALUE) return -1;