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>
(cherry picked from commit 8b4e6ccb13)
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 7af8307c40
commit bbac13c54a
No known key found for this signature in database
GPG key ID: B18E8928B3948D64

View file

@ -70,12 +70,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;