diff mbox

[FFmpeg-devel,V1,2/4] lavfi/sinc: fix memory leak in error handling path

Message ID 1568115568-14548-2-git-send-email-mypopydev@gmail.com
State Accepted
Commit 944d76a3e056c26bfa2b6459ec1888f0676a37f2
Headers show

Commit Message

Jun Zhao Sept. 10, 2019, 11:39 a.m. UTC
From: Jun Zhao <barryjzhao@tencent.com>

free work&pi_wraps in error handling path to avoid memory leak.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavfilter/asrc_sinc.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

Comments

Paul B Mahol Sept. 10, 2019, 1:06 p.m. UTC | #1
lgtm

On 9/10/19, Jun Zhao <mypopydev@gmail.com> wrote:
> From: Jun Zhao <barryjzhao@tencent.com>
>
> free work&pi_wraps in error handling path to avoid memory leak.
>
> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> ---
>  libavfilter/asrc_sinc.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/libavfilter/asrc_sinc.c b/libavfilter/asrc_sinc.c
> index 0135eb9..90f043d 100644
> --- a/libavfilter/asrc_sinc.c
> +++ b/libavfilter/asrc_sinc.c
> @@ -239,8 +239,11 @@ static int fir_to_phase(SincContext *s, float **h, int
> *len, int *post_len, floa
>      s->rdft = s->irdft = NULL;
>      s->rdft  = av_rdft_init(av_log2(work_len), DFT_R2C);
>      s->irdft = av_rdft_init(av_log2(work_len), IDFT_C2R);
> -    if (!s->rdft || !s->irdft)
> +    if (!s->rdft || !s->irdft) {
> +        av_free(pi_wraps);
> +        av_free(work);
>          return AVERROR(ENOMEM);
> +    }
>
>      av_rdft_calc(s->rdft, work);   /* Cepstral: */
>      UNPACK(work, work_len);
> --
> 1.7.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
mypopy@gmail.com Sept. 11, 2019, 2:31 a.m. UTC | #2
On Tue, Sep 10, 2019 at 9:06 PM Paul B Mahol <onemda@gmail.com> wrote:
>
> lgtm
>
Will apply, Thanks
diff mbox

Patch

diff --git a/libavfilter/asrc_sinc.c b/libavfilter/asrc_sinc.c
index 0135eb9..90f043d 100644
--- a/libavfilter/asrc_sinc.c
+++ b/libavfilter/asrc_sinc.c
@@ -239,8 +239,11 @@  static int fir_to_phase(SincContext *s, float **h, int *len, int *post_len, floa
     s->rdft = s->irdft = NULL;
     s->rdft  = av_rdft_init(av_log2(work_len), DFT_R2C);
     s->irdft = av_rdft_init(av_log2(work_len), IDFT_C2R);
-    if (!s->rdft || !s->irdft)
+    if (!s->rdft || !s->irdft) {
+        av_free(pi_wraps);
+        av_free(work);
         return AVERROR(ENOMEM);
+    }
 
     av_rdft_calc(s->rdft, work);   /* Cepstral: */
     UNPACK(work, work_len);