summaryrefslogtreecommitdiff
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-02-18 19:48:44 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-02-18 20:37:17 +0100
commit695a766bff4cd8414a84e58159506d72b4e44892 (patch)
treecd494a90655cfa00ba4b97e17818b5b675462356 /libavformat/utils.c
parent85921499c747a57cef4ae625cb85e6ebfa1bebf1 (diff)
ff_read_timestamp: check stream_index before using it as array index
Fixes out of array read Found-by: durandal_1707 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 009aeb031a..d59a02d951 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1767,7 +1767,10 @@ int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp,
static int64_t ff_read_timestamp(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit,
int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ))
{
- return wrap_timestamp(s->streams[stream_index], read_timestamp(s, stream_index, ppos, pos_limit));
+ int64_t ts = read_timestamp(s, stream_index, ppos, pos_limit);
+ if (stream_index >= 0)
+ ts = wrap_timestamp(s->streams[stream_index], ts);
+ return ts;
}
int ff_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags)