]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/h265_metadata_bsf: Check nb_units before accessing the first in h265_metadata...
authorMichael Niedermayer <michael@niedermayer.cc>
Tue, 30 Mar 2021 10:36:08 +0000 (12:36 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 1 Apr 2021 08:10:21 +0000 (10:10 +0200)
Fixes: null pointer dereference
Fixes: 32113/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-4803262287052800
Same as 0c48c332eeb2866d9353125f701e099c48889463

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/h265_metadata_bsf.c

index 59325c0471940b04619688c143513bc5dae30cad..d841839762b7aa15e3ee0d8e7619af3020b07569 100644 (file)
@@ -335,7 +335,7 @@ static int h265_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt,
     int err, i;
 
     // If an AUD is present, it must be the first NAL unit.
-    if (au->units[0].type == HEVC_NAL_AUD) {
+    if (au->nb_units && au->units[0].type == HEVC_NAL_AUD) {
         if (ctx->aud == BSF_ELEMENT_REMOVE)
             ff_cbs_delete_unit(au, 0);
     } else {