avcodec/cbs_av1: ensure Sequence Header unit content is always reference counted

Prevents a NULL pointer dereference.

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2020-09-29 11:14:07 -03:00
parent 052b4c3481
commit 233a99e191
1 changed files with 4 additions and 0 deletions

View File

@ -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);