From dfee7c0ea337e8bafadf2c5d55c7c80d9ddee175 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 3 Jun 2025 17:19:48 +0200 Subject: [PATCH 3/7] avcodec/psymodel: Use av_memdup() where appropriate Also "fixes" the inverted order of arguments in the av_malloc_array() calls and therefore part of ticket #11620. Signed-off-by: Andreas Rheinhardt --- libavcodec/psymodel.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libavcodec/psymodel.c b/libavcodec/psymodel.c index 890b13e1c8..1720e9b09b 100644 --- a/libavcodec/psymodel.c +++ b/libavcodec/psymodel.c @@ -37,8 +37,8 @@ av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens, ctx->avctx = avctx; ctx->ch = av_calloc(avctx->ch_layout.nb_channels, 2 * sizeof(ctx->ch[0])); ctx->group = av_calloc(num_groups, sizeof(ctx->group[0])); - ctx->bands = av_malloc_array (sizeof(ctx->bands[0]), num_lens); - ctx->num_bands = av_malloc_array (sizeof(ctx->num_bands[0]), num_lens); + ctx->bands = av_memdup(bands, num_lens * sizeof(ctx->bands[0])); + ctx->num_bands = av_memdup(num_bands, num_lens * sizeof(ctx->num_bands[0])); ctx->cutoff = avctx->cutoff; if (!ctx->ch || !ctx->group || !ctx->bands || !ctx->num_bands) { @@ -46,9 +46,6 @@ av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens, return AVERROR(ENOMEM); } - memcpy(ctx->bands, bands, sizeof(ctx->bands[0]) * num_lens); - memcpy(ctx->num_bands, num_bands, sizeof(ctx->num_bands[0]) * num_lens); - /* assign channels to groups (with virtual channels for coupling) */ for (i = 0; i < num_groups; i++) { /* NOTE: Add 1 to handle the AAC chan_config without modification. -- 2.45.2