diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-04-20 18:18:36 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-04-20 21:19:29 +0200 |
commit | 718e03e5f297564b828730dfc012fa3f6fbf576b (patch) | |
tree | 27aec99b25704a12c688ecf8bbfc059202cfb0a7 /libavcodec/mjpegdec.h | |
parent | f40e9b13554d88cbdd6cd2b4a3da2cbea9590f5d (diff) |
avcodec/jpeglsdec: Don't presume the context to contain a JLSState
Before 9b3c46a081a9f01559082bf7a154fc6be1e06c18 every call to
ff_jpegls_decode_picture() allocated and freed a JLSState. This commit
instead put said structure into the context of the JPEG-LS decoder to
avoid said allocation. But said function can also be called from other
MJPEG-based decoders and their contexts doesn't contain said structure,
leading to segfaults. This commit fixes this: The JLSState is now
allocated on the first call to ff_jpegls_decode_picture() and stored in
the context.
Found-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/mjpegdec.h')
-rw-r--r-- | libavcodec/mjpegdec.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libavcodec/mjpegdec.h b/libavcodec/mjpegdec.h index 0d69d9101b..2400a179f1 100644 --- a/libavcodec/mjpegdec.h +++ b/libavcodec/mjpegdec.h @@ -49,6 +49,8 @@ typedef struct ICCEntry { int length; } ICCEntry; +struct JLSState; + typedef struct MJpegDecodeContext { AVClass *class; AVCodecContext *avctx; @@ -163,6 +165,7 @@ typedef struct MJpegDecodeContext { enum AVPixelFormat hwaccel_sw_pix_fmt; enum AVPixelFormat hwaccel_pix_fmt; void *hwaccel_picture_private; + struct JLSState *jls_state; } MJpegDecodeContext; int ff_mjpeg_build_vlc(VLC *vlc, const uint8_t *bits_table, |