mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-23 04:24:35 +02:00
mov: don't overwrite existing indexes.
Prevents all kind of badness if files contain multiple indexes. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org
This commit is contained in:
parent
0399fe0fd2
commit
4f7c7624c0
@ -1727,6 +1727,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
|
|||||||
unsigned int stps_index = 0;
|
unsigned int stps_index = 0;
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
uint64_t stream_size = 0;
|
uint64_t stream_size = 0;
|
||||||
|
AVIndexEntry *mem;
|
||||||
|
|
||||||
/* adjust first dts according to edit list */
|
/* adjust first dts according to edit list */
|
||||||
if (sc->time_offset && mov->time_scale > 0) {
|
if (sc->time_offset && mov->time_scale > 0) {
|
||||||
@ -1755,12 +1756,13 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
|
|||||||
|
|
||||||
if (!sc->sample_count)
|
if (!sc->sample_count)
|
||||||
return;
|
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;
|
return;
|
||||||
st->index_entries = av_malloc(sc->sample_count*sizeof(*st->index_entries));
|
mem = av_realloc(st->index_entries, (st->nb_index_entries + sc->sample_count) * sizeof(*st->index_entries));
|
||||||
if (!st->index_entries)
|
if (!mem)
|
||||||
return;
|
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++) {
|
for (i = 0; i < sc->chunk_count; i++) {
|
||||||
current_offset = sc->chunk_offsets[i];
|
current_offset = sc->chunk_offsets[i];
|
||||||
@ -1844,12 +1846,13 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
|
|||||||
}
|
}
|
||||||
|
|
||||||
av_dlog(mov->fc, "chunk count %d\n", total);
|
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;
|
return;
|
||||||
st->index_entries = av_malloc(total*sizeof(*st->index_entries));
|
mem = av_realloc(st->index_entries, (st->nb_index_entries + total) * sizeof(*st->index_entries));
|
||||||
if (!st->index_entries)
|
if (!mem)
|
||||||
return;
|
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
|
// populate index
|
||||||
for (i = 0; i < sc->chunk_count; i++) {
|
for (i = 0; i < sc->chunk_count; i++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user