summaryrefslogtreecommitdiff
path: root/libavformat/mov.c
diff options
context:
space:
mode:
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>2007-01-24 15:46:59 +0000
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>2007-01-24 15:46:59 +0000
commit649348777e492b54cd980108ecac0caf77cea012 (patch)
treeb24a335ee26bc9aeadab291205b244217becc9de /libavformat/mov.c
parent08c88316854d5c011f298dc779b64ee64578ece1 (diff)
stop if current sample is higher than sample count
Originally committed as revision 7689 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/mov.c')
-rw-r--r--libavformat/mov.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 4e542cd55c..80fb0a3455 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1494,6 +1494,10 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
if (stsc_index + 1 < sc->sample_to_chunk_sz && i + 1 == sc->sample_to_chunk[stsc_index + 1].first)
stsc_index++;
for (j = 0; j < sc->sample_to_chunk[stsc_index].count; j++) {
+ if (current_sample >= sc->sample_count) {
+ av_log(mov->fc, AV_LOG_ERROR, "wrong sample count\n");
+ goto out;
+ }
keyframe = !sc->keyframe_count || current_sample + 1 == sc->keyframes[stss_index];
if (keyframe) {
distance = 0;
@@ -1509,8 +1513,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
current_dts += sc->stts_data[stts_index].duration / sc->time_rate;
distance++;
stts_sample++;
- if (current_sample + 1 < sc->sample_count)
- current_sample++;
+ current_sample++;
if (stts_index + 1 < sc->stts_count && stts_sample == sc->stts_data[stts_index].count) {
stts_sample = 0;
stts_index++;
@@ -1578,6 +1581,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
current_dts += chunk_duration / sc->time_rate;
}
}
+ out:
/* adjust sample count to avindex entries */
sc->sample_count = st->nb_index_entries;
}