From 10c68e99734676cfaea663e38b6ab916d6ec844c Mon Sep 17 00:00:00 2001 From: Ilya Sinitsyn Date: Wed, 14 Oct 2020 08:19:53 +0700 Subject: [PATCH] Fix wxMemoryFSHandler memory leaks in wxFileSystem unit test Use wxScopedPtr<> to ensure the handlers we use get freed. --- tests/filesys/filesystest.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/filesys/filesystest.cpp b/tests/filesys/filesystest.cpp index b17e271cab..e0213c42ad 100644 --- a/tests/filesys/filesystest.cpp +++ b/tests/filesys/filesystest.cpp @@ -22,6 +22,7 @@ #if wxUSE_FILESYSTEM #include "wx/fs_mem.h" +#include "wx/scopedptr.h" // ---------------------------------------------------------------------------- // helpers @@ -186,16 +187,16 @@ TEST_CASE("wxFileSystem::MemoryFSHandler", "[filesys][memoryfshandler][find]") AutoMemoryFSHandler() : m_handler(new wxMemoryFSHandler()) { - wxFileSystem::AddHandler(m_handler); + wxFileSystem::AddHandler(m_handler.get()); } ~AutoMemoryFSHandler() { - wxFileSystem::RemoveHandler(m_handler); + wxFileSystem::RemoveHandler(m_handler.get()); } private: - wxMemoryFSHandler* const m_handler; + wxScopedPtr const m_handler; } autoMemoryFSHandler; wxMemoryFSHandler::AddFile("foo.txt", "foo contents");