summaryrefslogtreecommitdiff
path: root/libavformat/mov.c
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2017-02-03 13:05:27 +0100
committerVittorio Giovara <vittorio.giovara@gmail.com>2017-02-10 16:26:16 -0500
commit53ea595eec984e3109310e8bb7ff4b5786d91057 (patch)
treedc037335491e6d6630ec20e21b64cb6771df5cc4 /libavformat/mov.c
parentce6d72d10776b03c6780d4aa676414ce002285d4 (diff)
mov: Rework stsc index validation
In order to avoid potential integer overflow change the comparison and make sure to use the same unsigned type for both elements.
Diffstat (limited to 'libavformat/mov.c')
-rw-r--r--libavformat/mov.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 2810960e87..11bcff035c 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1983,13 +1983,13 @@ static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0;
}
-static inline int mov_stsc_index_valid(int index, int count)
+static inline int mov_stsc_index_valid(unsigned int index, unsigned int count)
{
- return index + 1 < count;
+ return index < count - 1;
}
/* Compute the samples value for the stsc entry at the given index. */
-static inline int mov_get_stsc_samples(MOVStreamContext *sc, int index)
+static inline int mov_get_stsc_samples(MOVStreamContext *sc, unsigned int index)
{
int chunk_count;
@@ -3982,7 +3982,7 @@ static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp,
{
MOVStreamContext *sc = st->priv_data;
int sample, time_sample;
- int i;
+ unsigned int i;
sample = av_index_search_timestamp(st, timestamp, flags);
av_log(s, AV_LOG_TRACE, "stream %d, timestamp %"PRId64", sample %d\n", st->index, timestamp, sample);