]> git.sesse.net Git - ffmpeg/commit
avcodec/svq3: Fix segfault on allocation error, avoid allocations
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sun, 13 Sep 2020 00:25:16 +0000 (02:25 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Wed, 16 Sep 2020 22:09:08 +0000 (00:09 +0200)
commit96061c5a4f690c3ab49e4458701bb013fd3dd57f
tree3c168e5d047336881a5e40fdb6d6ffaecf90a18d
parent7d91f9271ee336da93b6871bf3306348ac1595a7
avcodec/svq3: Fix segfault on allocation error, avoid allocations

The very first thing the SVQ3 decoder currently does is allocating several
SVQ3Frames, a structure which contains members that need to be freed on
their own. If one of these allocations fails, the decoder calls its own
close function to not leak the already allocated SVQ3Frames. Yet said
function presumes that the SVQ3Frames have been successfully allocated
as there is no check before freeing the members that need to be freed.

This commit fixes this by making these frames part of the SVQ3Context,
thereby avoiding the allocations altogether. Notice that the pointers
to the frames have been retained in order to allow to just swap them as
the code already does.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/svq3.c