diff mbox series

[FFmpeg-devel,4/5] avcodec/h264_metadata_bsf: Check nb_units before accessing the first in h264_metadata_update_fragment()

Message ID 20210131215605.28190-4-michael@niedermayer.cc
State Accepted
Commit 0c48c332eeb2866d9353125f701e099c48889463
Headers show
Series [FFmpeg-devel,1/5] avformat/sbgdec: Use av_sat_add64() in str_to_time() | expand


Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Michael Niedermayer Jan. 31, 2021, 9:56 p.m. UTC
Fixes: null pointer dereference
Fixes: 29835/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-4712125383704576

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
 libavcodec/h264_metadata_bsf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series


diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index 6673a32601..a05a51f431 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -462,7 +462,7 @@  static int h264_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt,
     int err, i, has_sps, seek_point;
     // If an AUD is present, it must be the first NAL unit.
-    if (au->units[0].type == H264_NAL_AUD) {
+    if (au->nb_units && au->units[0].type == H264_NAL_AUD) {
         if (ctx->aud == BSF_ELEMENT_REMOVE)
             ff_cbs_delete_unit(au, 0);
     } else {