On Tue, Jan 5, 2016 at 11:16 AM, Paul B Mahol <one...@gmail.com> wrote: > On 1/5/16, Ganesh Ajjanagadde <gajja...@mit.edu> wrote: >> On Tue, Jan 5, 2016 at 11:06 AM, Paul B Mahol <one...@gmail.com> wrote: >>> On 1/2/16, Ganesh Ajjanagadde <gajja...@mit.edu> wrote: >>> [...] >>>> >>>> Thanks a lot for addressing this. But a client may not necessarily >>>> attempt initialization of the channel layouts first, so instead of >>>> do_nothing calls, shouldn't there be an equivalent for >>>> AVFilterFormats*? >>>> >>>> Of course, the commit message will need rewording. >>> >>> After second look I see no need for this code, the present code already >>> frees all allocated memory. >>> >>> Whichever instructions you used to expose leaks were flawed. >> >> care to explain: I did not know valgrind (as well as coverity) had >> such simple bugs if you are indeed correct? > > I didn't claim valgrind is buggy in this case, instead the way to > trigger leak is wrong. > > The ->list translates to ->channel_layouts and its freed on error IIRC.
Ok. Let us examine this carefully, and patiently step by step: 1. Patch to trigger leaks: diff --git a/libavfilter/formats.c b/libavfilter/formats.c index a2b19e7..dde30ec 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -422,7 +422,8 @@ AVFilterChannelLayouts *ff_all_channel_counts(void) if (!f || !ref) \ return AVERROR(ENOMEM); \ \ - tmp = av_realloc_array(f->refs, sizeof(*f->refs), f->refcount + 1); \ + /*tmp = av_realloc_array(f->refs, sizeof(*f->refs), f->refcount + 1);*/ \ + tmp = NULL; \ if (!tmp) { \ unref_fn(&f); \ return AVERROR(ENOMEM); \ I think you agree that this is a correct way to simulate. 2. Run valgrind before and after this patch, with the command: valgrind -v --leak-check=full --show-leak-kinds=all --log-file=/tmp/avfilter_leak ./ffmpeg_g -i ~/samples/h264/crop-to-container-dims-canon.mov -af compensationdelay -f null - > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel