diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2023-09-30 18:07:58 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2023-10-03 18:53:25 +0200 |
commit | 3ede6cc0f18c3da842d18153b860d911bdbfbde9 (patch) | |
tree | eab16dd8889007a3417026b2064afdcb2707f7e0 | |
parent | 8d12762b42c27ffc0b4ce9890bc622c96c524549 (diff) | |
download | ffmpeg-3ede6cc0f18c3da842d18153b860d911bdbfbde9.tar.gz |
avcodec/mpegvideo_dec: Check for existence of planes before accesses
Fixes segfaults with -debug +nomc -flags +gray (presuming
a build with --enable-gray).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r-- | libavcodec/mpegvideo_dec.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index aab2a4655a..c5e42e8ab6 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -249,10 +249,12 @@ static void gray_frame(AVFrame *frame) { int h_chroma_shift, v_chroma_shift; - av_pix_fmt_get_chroma_sub_sample(frame->format, &h_chroma_shift, &v_chroma_shift); - for (int i = 0; i < frame->height; i++) memset(frame->data[0] + frame->linesize[0] * i, 0x80, frame->width); + + if (!frame->data[1]) + return; + av_pix_fmt_get_chroma_sub_sample(frame->format, &h_chroma_shift, &v_chroma_shift); for (int i = 0; i < AV_CEIL_RSHIFT(frame->height, v_chroma_shift); i++) { memset(frame->data[1] + frame->linesize[1] * i, 0x80, AV_CEIL_RSHIFT(frame->width, h_chroma_shift)); |