1
0
Fork 0
forked from len0rd/rockbox

Codecs: mp4: Fix seek in files with single element in lookup_table

lookup_table offset shouldn't be zero terminated.
And fix possible out of bound access.

Change-Id: I212a5fcc1868a2ca519b0052b170e836276fe9de
This commit is contained in:
roman.artiukhin 2023-09-18 13:36:12 +03:00 committed by Solomon Peachy
parent 57a47ef67a
commit a45204f5df
2 changed files with 8 additions and 8 deletions

View file

@ -524,7 +524,7 @@ static bool read_chunk_stco(qtmovie_t *qtmovie, size_t chunk_len)
stream_seek(qtmovie->stream, qtmovie->res->sample_to_chunk_offset);
stream_read_sample_to_chunk(qtmovie->stream, &old_first, &old_frame);
stream_read_sample_to_chunk(qtmovie->stream, &new_first, &new_frame);
for (k = 1; k < numentries; ++k)
for (k = 1; k < numentries + 1; ++k)
{
for (; i < qtmovie->res->num_sample_to_chunks; ++i)
{
@ -548,9 +548,11 @@ static bool read_chunk_stco(qtmovie_t *qtmovie, size_t chunk_len)
qtmovie->res->lookup_table[idx++].sample = frame + (k - old_first) * old_frame;
}
}
/* zero-terminate the lookup table */
qtmovie->res->lookup_table[idx].sample = 0;
qtmovie->res->lookup_table[idx].offset = 0;
/* zero-terminate sample if it wasn't calculated */
if (idx < fit_numentries)
{
qtmovie->res->lookup_table[idx].sample = 0;
}
stream_seek(qtmovie->stream, current_offset);
if (size_remaining)