diff mbox

[FFmpeg-devel,V1,2/2] lavfi/avf_showspectrum: Fix the memory leak in error handle path

Message ID 1575370860-26345-2-git-send-email-mypopydev@gmail.com
State Accepted
Commit 46d2a67f80e60128791d3d254fc6c17db6b94db9
Headers show

Commit Message

Jun Zhao Dec. 3, 2019, 11:01 a.m. UTC
From: Jun Zhao <barryjzhao@tencent.com>

Fix the memory leak in error handle path.

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

Comments

Michael Niedermayer Dec. 4, 2019, 7:17 p.m. UTC | #1
On Tue, Dec 03, 2019 at 07:01:00PM +0800, Jun Zhao wrote:
> From: Jun Zhao <barryjzhao@tencent.com>
> 
> Fix the memory leak in error handle path.
> 
> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> ---
>  libavfilter/avf_showspectrum.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)

probably ok, iam not maintainer of this file though

thx

[...]
diff mbox

Patch

diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c
index d5785af..3a3ef7e 100644
--- a/libavfilter/avf_showspectrum.c
+++ b/libavfilter/avf_showspectrum.c
@@ -700,16 +700,15 @@  static int draw_legend(AVFilterContext *ctx, int samples)
 
     drawtext(s->outpicref, 2, outlink->h - 10, "CREATED BY LIBAVFILTER", 0);
     drawtext(s->outpicref, outlink->w - 2 - strlen(text) * 10, outlink->h - 10, text, 0);
+    av_freep(&text);
     if (s->stop) {
-        char *text = av_asprintf("Zoom: %d Hz - %d Hz", s->start, s->stop);
+        text = av_asprintf("Zoom: %d Hz - %d Hz", s->start, s->stop);
         if (!text)
             return AVERROR(ENOMEM);
         drawtext(s->outpicref, outlink->w - 2 - strlen(text) * 10, 3, text, 0);
         av_freep(&text);
     }
 
-    av_freep(&text);
-
     dst = s->outpicref->data[0] + (s->start_y - 1) * s->outpicref->linesize[0] + s->start_x - 1;
     for (x = 0; x < s->w + 1; x++)
         dst[x] = 200;