PR #25882 opened by sylvestre
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25882
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25882.patch

If av_buffer_ref() fails for the SMPTE 2094 APP5 metadata, the function
returned directly and leaked the HDR10+ buffer reference taken just
before. Go through the fail label so frame_data_uninit() releases it.

Regression since e1797cdd51 (avcodec/libvpxenc: Copy Smpte2094App5 metadata).
Noticed while reviewing Coverity (Firefox CID 1701832), which is itself
a false positive: it reports fd.hdr_smpte2094_app5 as leaked on the
success path, where ownership is transferred to the FIFO.



>From f503aa0d9e46b375838af52bba5b9a3748c1854e Mon Sep 17 00:00:00 2001
From: Sylvestre Ledru <[email protected]>
Date: Mon, 9 Nov 2026 11:29:30 +0100
Subject: [PATCH] avcodec/libvpxenc: fix HDR10+ side data leak on OOM in
 frame_data_submit()

If av_buffer_ref() fails for the SMPTE 2094 APP5 metadata, the function
returned directly and leaked the HDR10+ buffer reference taken just
before. Go through the fail label so frame_data_uninit() releases it.

Regression since e1797cdd51 (avcodec/libvpxenc: Copy Smpte2094App5 metadata).
Noticed while reviewing Coverity (Firefox CID 1701832), which is itself
a false positive: it reports fd.hdr_smpte2094_app5 as leaked on the
success path, where ownership is transferred to the FIFO.
---
 libavcodec/libvpxenc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 942e28dd733..076cbc0fe35 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -387,8 +387,10 @@ static int frame_data_submit(AVCodecContext *avctx, AVFifo 
*fifo,
     sd = av_frame_get_side_data(frame, 
AV_FRAME_DATA_DYNAMIC_HDR_SMPTE_2094_APP5);
     if (sd) {
         fd.hdr_smpte2094_app5 = av_buffer_ref(sd->buf);
-        if (!fd.hdr_smpte2094_app5)
-            return AVERROR(ENOMEM);
+        if (!fd.hdr_smpte2094_app5) {
+            ret = AVERROR(ENOMEM);
+            goto fail;
+        }
     }
 
     fd.duration     = frame->duration;
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to