[FFmpeg-cvslog] avfilter/vf_photosensitivity: fix memleak

Paul B Mahol git at videolan.org
Mon Sep 30 21:41:22 EEST 2019


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Sep 30 20:37:25 2019 +0200| [056bc9393ea78d24982cdf555c0bb3fcfe734262] | committer: Paul B Mahol

avfilter/vf_photosensitivity: fix memleak

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=056bc9393ea78d24982cdf555c0bb3fcfe734262
---

 libavfilter/vf_photosensitivity.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_photosensitivity.c b/libavfilter/vf_photosensitivity.c
index 4559454846..e05c187eeb 100644
--- a/libavfilter/vf_photosensitivity.c
+++ b/libavfilter/vf_photosensitivity.c
@@ -220,6 +220,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     int this_badness, current_badness, fixed_badness, new_badness, i, res;
     PhotosensitivityFrame ef;
     AVFrame *src, *out;
+    int free_in = 0;
     float factor;
     AVDictionary **metadata;
 
@@ -270,12 +271,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             s->history[s->history_pos] = this_badness;
         }
         src = s->last_frame_av;
+        free_in = 1;
     }
     s->history_pos = (s->history_pos + 1) % s->nb_frames;
 
     out = ff_get_video_buffer(outlink, in->width, in->height);
     if (!out) {
-        av_frame_free(&in);
+        if (free_in == 1)
+            av_frame_free(&in);
         return AVERROR(ENOMEM);
     }
     av_frame_copy_props(out, in);
@@ -296,6 +299,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         av_dict_set(metadata, "lavfi.photosensitivity.factor", value, 0);
     }
     av_frame_copy(out, src);
+    if (free_in == 1)
+        av_frame_free(&in);
     return ff_filter_frame(outlink, out);
 }
 



More information about the ffmpeg-cvslog mailing list