]> git.sesse.net Git - ffmpeg/commit
avfilter/vf_showpalette: Fix double-free of AVFilterFormats on error
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Fri, 7 Aug 2020 11:23:30 +0000 (13:23 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sun, 23 Aug 2020 21:27:50 +0000 (23:27 +0200)
commit76909c97c68c79d3c0353de83418a112595e9798
tree45a69b77c4c3ebec05fd4542d5458c8586bbd826
parent44e376500fd0a5e6b9ca1611e645feeb50de1ac5
avfilter/vf_showpalette: Fix double-free of AVFilterFormats on error

The query_formats function of the showpalette filter tries to allocate
two lists of formats which on success are attached to more permanent objects
(AVFilterLinks) for storage afterwards. If attaching a list to an
AVFilterLink succeeds, the link becomes one (in this case the only one)
of the owners of the list. Yet if attaching the first list to its link
succeeds and attaching the second list fails, both lists were manually
freed, which means that the first link's pointer to the first list
becomes dangling and there will be a double-free when the first link is
cleaned up automatically.

This commit fixes this by removing the custom free code; this will
temporarily add a leaking codepath (if attaching a list to a link fails,
the list will leak), but this will be fixed shortly by making sure that
an AVFilterFormats without owner will be automatically freed when
attaching it to an AVFilterLink fails. Notice at most one list leaks
because as of this commit a new list is only allocated after the old list
has been successfully attached to a link.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavfilter/vf_showpalette.c