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.