diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-06-01 02:23:32 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-06-01 02:23:32 +0200 |
commit | 615e73ab4f8cd85e490c7d141fd710385bfaa8ac (patch) | |
tree | f8e3627021219f0026059e91e84e6d2b9808f185 /libavcodec/psymodel.c | |
parent | 1a903f0d1e989bc6fba98fdcbf8e222b5b8cfc6c (diff) | |
parent | 03927cb73399e6f07185fc7f8851d7612b4187b6 (diff) | |
download | ffmpeg-615e73ab4f8cd85e490c7d141fd710385bfaa8ac.tar.gz |
Merge commit '03927cb73399e6f07185fc7f8851d7612b4187b6'
* commit '03927cb73399e6f07185fc7f8851d7612b4187b6':
psymodel: Check memory allocation
Conflicts:
libavcodec/psymodel.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/psymodel.c')
-rw-r--r-- | libavcodec/psymodel.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libavcodec/psymodel.c b/libavcodec/psymodel.c index 059cbefe37..824eefb79e 100644 --- a/libavcodec/psymodel.c +++ b/libavcodec/psymodel.c @@ -39,6 +39,12 @@ av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens, ctx->group = av_mallocz_array(sizeof(ctx->group[0]), num_groups); ctx->bands = av_malloc_array (sizeof(ctx->bands[0]), num_lens); ctx->num_bands = av_malloc_array (sizeof(ctx->num_bands[0]), num_lens); + + if (!ctx->ch || !ctx->group || !ctx->bands || !ctx->num_bands) { + ff_psy_end(ctx); + 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); @@ -99,6 +105,8 @@ av_cold struct FFPsyPreprocessContext* ff_psy_preprocess_init(AVCodecContext *av int i; float cutoff_coeff = 0; ctx = av_mallocz(sizeof(FFPsyPreprocessContext)); + if (!ctx) + return NULL; ctx->avctx = avctx; if (avctx->cutoff > 0) @@ -113,6 +121,10 @@ av_cold struct FFPsyPreprocessContext* ff_psy_preprocess_init(AVCodecContext *av cutoff_coeff, 0.0, 0.0); if (ctx->fcoeffs) { ctx->fstate = av_mallocz_array(sizeof(ctx->fstate[0]), avctx->channels); + if (!ctx->fstate) { + av_free(ctx); + return NULL; + } for (i = 0; i < avctx->channels; i++) ctx->fstate[i] = ff_iir_filter_init_state(FILT_ORDER); } |