aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/x86/lossless_audiodsp_init.c
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 01:09:09 +0200
commitff0706cde8b1a1f483e26c0ccac117c23b23d604 (patch)
treebd0d4da1a3118346b27a666684ed701f7b33efed /libavcodec/x86/lossless_audiodsp_init.c
parentd4b9e117ceb6356cbcdc9ca81ec9c6c4b90efdae (diff)
downloadffmpeg-ff0706cde8b1a1f483e26c0ccac117c23b23d604.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>
Diffstat (limited to 'libavcodec/x86/lossless_audiodsp_init.c')
0 files changed, 0 insertions, 0 deletions