]> git.sesse.net Git - ffmpeg/commit
avcodec/ffv1: Fix segfaults on allocation error
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Mon, 14 Sep 2020 02:58:34 +0000 (04:58 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Wed, 16 Sep 2020 22:09:07 +0000 (00:09 +0200)
commita0750f412ade5a969b1f90e038d707d531c97342
tree6abf51de1886e7a66c2e2104a9a9f5c97892a9bf
parent8de4a132ff5cf9efa1c35c78c881dc22ba255c10
avcodec/ffv1: Fix segfaults on allocation error

When allocating FFV1 slice contexts fails, ff_ffv1_init_slice_contexts()
frees everything that it has allocated, yet it does not reset the
counter for the number of allocated slice contexts. This inconsistent
state leads to segfaults lateron in ff_ffv1_close(), because said
function presumes that the slice contexts have been allocated.
Fix this by making sure that the number of slice contexts on error is
consistent (namely zero).

(This issue only affected the FFV1 decoder, because the encoder does not
clean up after itself on init failure.)

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/ffv1.c