From a62a35e1db47b7dee160ed24dca4b19f982eb312 Mon Sep 17 00:00:00 2001 From: Max Kellermann <max@musicpd.org> Date: Tue, 24 Aug 2021 12:32:44 +0200 Subject: [PATCH] lib/ffmpeg/Filter: remove FilterContext destructor Fixes potential double-free bugs which currently did not occur because the destructors happened to be called in the right order. --- src/lib/ffmpeg/Filter.hxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/ffmpeg/Filter.hxx b/src/lib/ffmpeg/Filter.hxx index 8990bb6f1..3cf11546d 100644 --- a/src/lib/ffmpeg/Filter.hxx +++ b/src/lib/ffmpeg/Filter.hxx @@ -101,10 +101,10 @@ public: FilterContext(FilterContext &&src) noexcept :context(std::exchange(src.context, nullptr)) {} - ~FilterContext() noexcept { - if (context != nullptr) - avfilter_free(context); - } + /* note: we don't need a destructor calling avfilter_free() + here because the AVFilterGraph owns and frees all the + AVFilterContext instances */ + // TODO: do we really need this wrapper class anymore? FilterContext &operator=(FilterContext &&src) noexcept { using std::swap;