From 233a99e1915ef237d2ef298db97680c323dfdd23 Mon Sep 17 00:00:00 2001 From: James Almer Date: Tue, 29 Sep 2020 11:14:07 -0300 Subject: [PATCH] avcodec/cbs_av1: ensure Sequence Header unit content is always reference counted Prevents a NULL pointer dereference. Signed-off-by: James Almer --- libavcodec/cbs_av1.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c index 9ae2f59872..a40c91adff 100644 --- a/libavcodec/cbs_av1.c +++ b/libavcodec/cbs_av1.c @@ -1076,6 +1076,10 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, av_buffer_unref(&priv->sequence_header_ref); priv->sequence_header = NULL; + err = ff_cbs_make_unit_refcounted(ctx, unit); + if (err < 0) + return err; + priv->sequence_header_ref = av_buffer_ref(unit->content_ref); if (!priv->sequence_header_ref) return AVERROR(ENOMEM);