Commit 948010e6ab for ffmpeg
commit 948010e6ab62b5fe567d9d286e324d7679d62689
Author: Martin Mirchev <mmirchev@comp.nus.edu.sg>
Date: Mon Nov 30 15:18:11 2026 +0800
avformat/mov: reset the ctts allocation size when freeing ctts_data
mov_read_ctts() frees an earlier ctts table but kept its
ctts_allocated_size, so av_fast_realloc(NULL, ...) saw a large enough
size, returned the NULL it was given, and a file with a second ctts box
in the same track failed with "Cannot allocate memory".
Reset the size along with the free, as mov_merge_tts_data() does.
Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
diff --git a/libavformat/mov.c b/libavformat/mov.c
index bf30384e47..68b43c45c2 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4159,6 +4159,7 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (entries >= UINT_MAX / sizeof(*sc->ctts_data))
return AVERROR_INVALIDDATA;
av_freep(&sc->ctts_data);
+ sc->ctts_allocated_size = 0;
sc->ctts_data = av_fast_realloc(NULL, &sc->ctts_allocated_size, entries * sizeof(*sc->ctts_data));
if (!sc->ctts_data)
return AVERROR(ENOMEM);