avcodec/mjpegenc: Fix segfault when freeing incomplete context
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Tue, 30 Mar 2021 21:20:49 +0000 (23:20 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Fri, 2 Apr 2021 19:39:04 +0000 (21:39 +0200)
commit5e2e8e1b9e2877062ae881ae68a69b4e12f6ed13
tree8edb89b51de7f8565cfe4b17cb84fa76a3619fff
parent28dd12c9b7518adc2bda4ca980603504b32298cf
avcodec/mjpegenc: Fix segfault when freeing incomplete context

When allocating the MJpegContext fails (or if the dimensions run afoul
of the 65500x65500 limit), an attempt to free a subbuffer of said
context leads to a segfault in ff_mjpeg_encode_close().
Seems to be a regression since 467d9e27e0cb2bf74f41dc832f2f8d191ba58ec9.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 84ac35ecb8a53bf313b468b5a9f1b0617f2a3de2)
libavcodec/mjpegenc.c