]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/h264_slice: Check sps in h264_slice_header_init()
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 20 Mar 2021 16:02:36 +0000 (17:02 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 26 Mar 2021 15:00:14 +0000 (16:00 +0100)
Fixes: null pointer dereference
Fixes: h264_slice_header_init.mp4
Found-by: Rafael Dutra <rafael.dutra@cispa.de>
Tested-by: Rafael Dutra <rafael.dutra@cispa.de>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/h264_slice.c

index 14b945756be73e79e5b5e748336d97be5eaecae8..84b5710ab4178dadd9c6c7545792a23dac29cafe 100644 (file)
@@ -922,6 +922,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);