]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/af_anequalizer: Fix memleak when inserting pad fails
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sat, 22 Aug 2020 01:23:51 +0000 (03:23 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Wed, 26 Aug 2020 21:52:56 +0000 (23:52 +0200)
It has been forgotten to free the name of the second outpad if attaching
the first one to the AVFilterContext fails. Fixing this is easy: Only
prepare the second outpad after (and if) the first outpad has been
successfully attached to the AVFilterContext.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavfilter/af_anequalizer.c

index 177e1c7b3977a8eabc01698d0811a271dbe22f9b..26cf835727f4afed86d94ea960eb8cd7c7470436 100644 (file)
@@ -199,6 +199,12 @@ static av_cold int init(AVFilterContext *ctx)
     if (!pad.name)
         return AVERROR(ENOMEM);
 
+    ret = ff_insert_outpad(ctx, 0, &pad);
+    if (ret < 0) {
+        av_freep(&pad.name);
+        return ret;
+    }
+
     if (s->draw_curves) {
         vpad = (AVFilterPad){
             .name         = av_strdup("out1"),
@@ -206,18 +212,8 @@ static av_cold int init(AVFilterContext *ctx)
             .config_props = config_video,
         };
         if (!vpad.name) {
-            av_freep(&pad.name);
             return AVERROR(ENOMEM);
         }
-    }
-
-    ret = ff_insert_outpad(ctx, 0, &pad);
-    if (ret < 0) {
-        av_freep(&pad.name);
-        return ret;
-    }
-
-    if (s->draw_curves) {
         ret = ff_insert_outpad(ctx, 1, &vpad);
         if (ret < 0) {
             av_freep(&vpad.name);