avcodec/h264_metadata_bsf: Check nb_units before accessing the first in h264_metadata_update_fragment()

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>
This commit is contained in:
Michael Niedermayer 2021-01-31 22:36:52 +01:00
parent 4e7dbca74c
commit 0c48c332ee

View File

@ -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 {