[FFmpeg-devel] [PATCH 2/6] avcodec/h264_slice: Check sps in h264_slice_header_init()

Michael Niedermayer michael at niedermayer.cc
Mon Mar 22 22:58:29 EET 2021


Fixes: null pointer dereference
Fixes: h264_slice_header_init.mp4

Found-by: Rafael Dutra <rafael.dutra at cispa.de>
Tested-by: Rafael Dutra <rafael.dutra at cispa.de>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavcodec/h264_slice.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 910d8b8848..62f7a61aed 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -921,6 +921,11 @@ static int h264_slice_header_init(H264Context *h)
     const SPS *sps = h->ps.sps;
     int i, ret;
 
+    if (!sps) {
+        ret = AVERROR_INVALIDDATA;
+        goto fail;
+    }
+
     ff_set_sar(h->avctx, sps->sar);
     av_pix_fmt_get_chroma_sub_sample(h->avctx->pix_fmt,
                                      &h->chroma_x_shift, &h->chroma_y_shift);
-- 
2.17.1



More information about the ffmpeg-devel mailing list