aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/mov.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-03-30 22:10:17 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-03-30 22:10:17 +0200
commit2b6325cacb6def8e9de0455f575b51a8bd90b12c (patch)
tree9975f34681673f4ce96537ea6684ff0fa8f5df89 /libavformat/mov.c
parent96df29c318ff64cb6ac706c11cbf932d96962fd7 (diff)
parentb691fd7a4dfca766075c022922a75cdbca4e6d92 (diff)
downloadffmpeg-2b6325cacb6def8e9de0455f575b51a8bd90b12c.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: h264: drop ff_h264_ prefix from static function ff_h264_decode_rbsp_trailing() h264: Make ff_h264_decode_end() static, it is not used externally. output-example: K&R formatting cosmetics, comment spelling fixes avf: make the example output the proper message avf: fix audio writing in the output-example mov: don't overwrite existing indexes. lzw: fix potential integer overflow. truemotion: forbid invalid VLC bitsizes and token values. truemotion2: handle out-of-frame motion vectors through edge extension. configure: Check for a different SDL function Conflicts: configure doc/examples/muxing.c libavcodec/truemotion2.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/mov.c')
-rw-r--r--libavformat/mov.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 0e9566fe3a..248620be68 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1803,6 +1803,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
unsigned int stps_index = 0;
unsigned int i, j;
uint64_t stream_size = 0;
+ AVIndexEntry *mem;
/* adjust first dts according to edit list */
if ((sc->empty_duration || sc->start_time) && mov->time_scale > 0) {
@@ -1832,12 +1833,13 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
if (!sc->sample_count || st->nb_index_entries)
return;
- if (sc->sample_count >= UINT_MAX / sizeof(*st->index_entries))
+ if (sc->sample_count >= UINT_MAX / sizeof(*st->index_entries) - st->nb_index_entries)
return;
- st->index_entries = av_malloc(sc->sample_count*sizeof(*st->index_entries));
- if (!st->index_entries)
+ mem = av_realloc(st->index_entries, (st->nb_index_entries + sc->sample_count) * sizeof(*st->index_entries));
+ if (!mem)
return;
- st->index_entries_allocated_size = sc->sample_count*sizeof(*st->index_entries);
+ st->index_entries = mem;
+ st->index_entries_allocated_size = (st->nb_index_entries + sc->sample_count) * sizeof(*st->index_entries);
for (i = 0; i < sc->chunk_count; i++) {
current_offset = sc->chunk_offsets[i];
@@ -1921,12 +1923,13 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
}
av_dlog(mov->fc, "chunk count %d\n", total);
- if (total >= UINT_MAX / sizeof(*st->index_entries))
+ if (total >= UINT_MAX / sizeof(*st->index_entries) - st->nb_index_entries)
return;
- st->index_entries = av_malloc(total*sizeof(*st->index_entries));
- if (!st->index_entries)
+ mem = av_realloc(st->index_entries, (st->nb_index_entries + total) * sizeof(*st->index_entries));
+ if (!mem)
return;
- st->index_entries_allocated_size = total*sizeof(*st->index_entries);
+ st->index_entries = mem;
+ st->index_entries_allocated_size = (st->nb_index_entries + total) * sizeof(*st->index_entries);
// populate index
for (i = 0; i < sc->chunk_count; i++) {