]> git.sesse.net Git - ffmpeg/commit
avcodec/movtextdec: Fix leaks of strings upon reallocation failure
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sat, 17 Oct 2020 10:32:54 +0000 (12:32 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Mon, 19 Oct 2020 02:52:48 +0000 (04:52 +0200)
commit38cdd27e9b36183a74c19859a8092aca6e82d712
treec2780e609ac07e4b4676993f8ae0769af46ddf4c
parent5758620560f1aa329a26ca1585dc0dbd903522c4
avcodec/movtextdec: Fix leaks of strings upon reallocation failure

Up until now, the 3GPP Timed Text decoder used av_dynarray_add()
for a list of font entries, a structure which contains an allocated
string. The font entries are owned by the pointers in the dynamic array
and are therefore unsuitable for av_dynarray_add() which simply frees
the array, but not the font entries and of course not the strings. The
latter all leak if reallocating the dynamic array fails.

This commit fixes this. It stops reallocating the array altogether:
After all, the final number of elements (pending errors) is already
known in advance.

Furthermore, the font entries are now the entries of the new array,
i.e. the font entries are no longer allocated separately. This also
removes one level of indirection.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/movtextdec.c