[FFmpeg-devel,2/2] fftools/ffmpeg_filter: fix memory leak issue.

Submitted by Jun Zhao on June 13, 2018, 1:48 p.m.

Details

Message ID 1528897739-3704-2-git-send-email-mypopydev@gmail.com
State New
Headers show

Commit Message

Jun Zhao June 13, 2018, 1:48 p.m.
need to call av_bprint_finalize to free the memory source to match
av_bprint_init.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
---
 fftools/ffmpeg_filter.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Nicolas George June 13, 2018, 1:59 p.m.
Jun Zhao (2018-06-13):
> need to call av_bprint_finalize to free the memory source to match
> av_bprint_init.

No, this buffer is never allocated dynamically.

Regards,
mypopy@gmail.com June 14, 2018, 2:36 a.m.
On Wed, Jun 13, 2018 at 9:59 PM Nicolas George <george@nsup.org> wrote:
>
> Jun Zhao (2018-06-13):
> > need to call av_bprint_finalize to free the memory source to match
> > av_bprint_init.
>
> No, this buffer is never allocated dynamically.
>
> Regards,
Thanks the comments, I think I have some misunderstand for bprint API,
will double-check this part.
>
> --
>   Nicolas George
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Patch hide | download patch | download mbox

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 068f499..a294e43 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -789,8 +789,11 @@  static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
 
 
     if ((ret = avfilter_graph_create_filter(&ifilter->filter, buffer_filt, name,
-                                            args.str, NULL, fg->graph)) < 0)
+                                            args.str, NULL, fg->graph)) < 0) {
+        av_bprint_finalize(&args, NULL);
         goto fail;
+    }
+    av_bprint_finalize(&args, NULL);
     par->hw_frames_ctx = ifilter->hw_frames_ctx;
     ret = av_buffersrc_parameters_set(ifilter->filter, par);
     if (ret < 0)
@@ -890,8 +893,11 @@  static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
 
     if ((ret = avfilter_graph_create_filter(&ifilter->filter, abuffer_filt,
                                             name, args.str, NULL,
-                                            fg->graph)) < 0)
+                                            fg->graph)) < 0) {
+        av_bprint_finalize(&args, NULL);
         return ret;
+    }
+    av_bprint_finalize(&args, NULL);
     last_filter = ifilter->filter;
 
 #define AUTO_INSERT_FILTER_INPUT(opt_name, filter_name, arg) do {                 \