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>
This commit is contained in:
Jiasheng Jiang
2025-08-05 19:31:15 +00:00
committed by Michael Niedermayer
parent d5040b5560
commit 8b4e6ccb13

View File

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