aboutsummaryrefslogtreecommitdiffstats
path: root/fftools
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-12-25 14:17:10 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-04-08 11:56:17 +0200
commit63277aa98e6731ed933c7ca3314239d80c67a945 (patch)
tree1f8fcd37ff861dba3cf9677e4fe70c7b399ae64b /fftools
parent0155d5cd744bae026e5e4215f362ff5249f07cb7 (diff)
downloadffmpeg-63277aa98e6731ed933c7ca3314239d80c67a945.tar.gz
avcodec/mpegvideo: Fix memleak upon allocation error
When slice-threading is used, ff_mpv_common_init() duplicates the first MpegEncContext and allocates some buffers for each MpegEncContext (the first as well as the copies). But the count of allocated MpegEncContexts is not updated until after everything has been allocated and if an error happens after the first one has been allocated, only the first one is freed; the others leak. This commit fixes this: The count is now set before the copies are allocated. Furthermore, the copies are now created and initialized before the first MpegEncContext, so that the buffers exclusively owned by each MpegEncContext are still NULL in the src MpegEncContext so that no double-free happens upon allocation failure. Given that this effectively touches every line of the init code, it has also been factored out in a function of its own in order to remove code duplication with the same code in ff_mpv_common_frame_size_change() (which was never called when using more than one slice (and if it were, there would be potential double-frees)). Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> (cherry picked from commit ff0706cde8b1a1f483e26c0ccac117c23b23d604)
Diffstat (limited to 'fftools')
0 files changed, 0 insertions, 0 deletions