diff options
author | Paul B Mahol <onemda@gmail.com> | 2018-01-10 18:38:01 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2018-01-10 18:38:01 +0100 |
commit | 3c29f68b4db316c5d2b126619220cfa4255eacd6 (patch) | |
tree | 19b58452a087d5b3c306fbc39a4f9d77b3cac1f5 /libavfilter/af_aiir.c | |
parent | 16ba6a8ad14183d2f8947e58a8cb9bae519bc430 (diff) | |
download | ffmpeg-3c29f68b4db316c5d2b126619220cfa4255eacd6.tar.gz |
avfilter/af_aiir: do not leak memory on failure in convert_zp2tf()
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter/af_aiir.c')
-rw-r--r-- | libavfilter/af_aiir.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c index 0bf9e4f844..c60f339411 100644 --- a/libavfilter/af_aiir.c +++ b/libavfilter/af_aiir.c @@ -404,7 +404,7 @@ static int expand(AVFilterContext *ctx, double *pz, int nb, double *coeffs) static int convert_zp2tf(AVFilterContext *ctx, int channels) { AudioIIRContext *s = ctx->priv; - int ch, i, j, ret; + int ch, i, j, ret = 0; for (ch = 0; ch < channels; ch++) { IIRChannel *iir = &s->iir[ch]; @@ -412,21 +412,19 @@ static int convert_zp2tf(AVFilterContext *ctx, int channels) topc = av_calloc((iir->nb_ab[0] + 1) * 2, sizeof(*topc)); botc = av_calloc((iir->nb_ab[1] + 1) * 2, sizeof(*botc)); - if (!topc || !botc) - return AVERROR(ENOMEM); + if (!topc || !botc) { + ret = AVERROR(ENOMEM); + goto fail; + } ret = expand(ctx, iir->ab[0], iir->nb_ab[0], botc); if (ret < 0) { - av_free(topc); - av_free(botc); - return ret; + goto fail; } ret = expand(ctx, iir->ab[1], iir->nb_ab[1], topc); if (ret < 0) { - av_free(topc); - av_free(botc); - return ret; + goto fail; } for (j = 0, i = iir->nb_ab[1]; i >= 0; j++, i--) { @@ -439,11 +437,14 @@ static int convert_zp2tf(AVFilterContext *ctx, int channels) } iir->nb_ab[0]++; +fail: av_free(topc); av_free(botc); + if (ret < 0) + break; } - return 0; + return ret; } static int decompose_zp2biquads(AVFilterContext *ctx, int channels) |