]> git.sesse.net Git - ffmpeg/commit
avcodec/movtextdec: Fix leaks on (re)allocation failure
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sat, 17 Oct 2020 13:18:00 +0000 (15:18 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Mon, 19 Oct 2020 02:59:08 +0000 (04:59 +0200)
commit94ad68ee17420996c9b003f142717d82b52c0915
treee679d70339db11e2610fc29038073931ba095483
parentc33b9fa74b6f167f472bd26e6ffa3cb796084c77
avcodec/movtextdec: Fix leaks on (re)allocation failure

Up until now, the 3GPP Timed Text decoder used av_dynarray_add()
for a list of style entries. Said entries are individually allocated
and owned by the pointers in the dynamic array and are therefore
unsuitable for av_dynarray_add() which simply frees the array,
but not the entries on error. In this case the intended new entry
also leaks because it has been forgotten to free it.

This commit fixes this. It is now allocated in one go and not
reallocated multiple times (and it won't be overallocated any more).
After all, the final number of elements (pending errors) is already
known in advance.

Furthermore, the style entries are now the entries of the new array,
i.e. they 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