diff options
author | Joakim Plate <elupus@ecce.se> | 2011-09-14 19:42:33 +0200 |
---|---|---|
committer | Joakim Plate <elupus@ecce.se> | 2011-09-14 19:53:45 +0200 |
commit | 7bcd81299a83b28ee8266079646470dd3e02f2ef (patch) | |
tree | b57979cadd081266b2b53f1d1b25791a256e1666 /libavformat | |
parent | d9d7174d70cb291ce9fc7a5e1fc1a420bbb729cb (diff) | |
download | ffmpeg-7bcd81299a83b28ee8266079646470dd3e02f2ef.tar.gz |
[wtv] Check return value of avio_seek and avoid modifying state if it fails
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/wtvdec.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c index e27fa14a6a..af0b711a0a 100644 --- a/libavformat/wtvdec.c +++ b/libavformat/wtvdec.c @@ -997,19 +997,23 @@ static int read_seek(AVFormatContext *s, int stream_index, i = ff_index_search_timestamp(wtv->index_entries, wtv->nb_index_entries, ts_relative, flags); if (i < 0) { - if (wtv->last_valid_pts == AV_NOPTS_VALUE || ts < wtv->last_valid_pts) - avio_seek(pb, 0, SEEK_SET); - else if (st->duration != AV_NOPTS_VALUE && ts_relative > st->duration && wtv->nb_index_entries) - avio_seek(pb, wtv->index_entries[wtv->nb_index_entries - 1].pos, SEEK_SET); + if (wtv->last_valid_pts == AV_NOPTS_VALUE || ts < wtv->last_valid_pts) { + if (avio_seek(pb, 0, SEEK_SET) < 0) + return -1; + } else if (st->duration != AV_NOPTS_VALUE && ts_relative > st->duration && wtv->nb_index_entries) { + if (avio_seek(pb, wtv->index_entries[wtv->nb_index_entries - 1].pos, SEEK_SET) < 0) + return -1; + } if (parse_chunks(s, SEEK_TO_PTS, ts, 0) < 0) return AVERROR(ERANGE); return 0; } + if (avio_seek(pb, wtv->index_entries[i].pos, SEEK_SET) < 0) + return -1; wtv->pts = wtv->index_entries[i].timestamp; if (wtv->epoch != AV_NOPTS_VALUE) wtv->pts += wtv->epoch; wtv->last_valid_pts = wtv->pts; - avio_seek(pb, wtv->index_entries[i].pos, SEEK_SET); return 0; } |