aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiasheng Jiang <jiashengjiangcool@gmail.com>2025-08-05 19:31:15 +0000
committerMichael Niedermayer <michael@niedermayer.cc>2025-08-07 03:07:43 +0200
commit8b4e6ccb13f10752bc5c2a963478c7f3764a0cfe (patch)
tree505f0db69e7cc36061783734a0eb96dbb129882c
parentd5040b5560c95cdbf134b5e4b1ee287568ef9fd8 (diff)
downloadffmpeg-8b4e6ccb13f10752bc5c2a963478c7f3764a0cfe.tar.gz
libavcodec/videotoolbox_vp9: Move av_malloc() to avoid memory leak
Move av_malloc() after the check for subsampling to avoid memory leak if subsampling < 0 and av_malloc() succeeds. Fixes: a41a2efc85 ("lavc/videotoolbox: add VP9 hardware acceleration") Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/videotoolbox_vp9.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libavcodec/videotoolbox_vp9.c b/libavcodec/videotoolbox_vp9.c
index de7fc0c935..f2cb34fca4 100644
--- a/libavcodec/videotoolbox_vp9.c
+++ b/libavcodec/videotoolbox_vp9.c
@@ -71,12 +71,12 @@ CFDataRef ff_videotoolbox_vpcc_extradata_create(AVCodecContext *avctx)
uint8_t *vt_extradata;
int subsampling = get_vpx_chroma_subsampling(avctx->sw_pix_fmt, avctx->chroma_sample_location);
- vt_extradata_size = 1 + 3 + 6 + 2;
- vt_extradata = av_malloc(vt_extradata_size);
-
if (subsampling < 0)
return NULL;
+ vt_extradata_size = 1 + 3 + 6 + 2;
+ vt_extradata = av_malloc(vt_extradata_size);
+
if (!vt_extradata)
return NULL;