From bc7bff4a0ee668249488ff6168136dd39e0a9362 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 8 Jun 2013 00:41:22 +0200 Subject: Fix memory leak in FileDialogHelper_Impl::createMatcher/addFilters. Before resetting mpMatcher to a new value check whether the current value needs to be deleted first. Change-Id: I26039c19483621d809dbd8474b86254948efc9f6 Reviewed-on: https://gerrit.libreoffice.org/4194 Reviewed-by: David Tardon Tested-by: David Tardon --- sfx2/source/dialog/filedlghelper.cxx | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sfx2') diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index c9ab00c7c704..a927cfe35e74 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -1769,6 +1769,9 @@ void FileDialogHelper_Impl::setFilter( const OUString& rFilter ) // ------------------------------------------------------------------------ void FileDialogHelper_Impl::createMatcher( const String& rFactory ) { + if (mbDeleteMatcher) + delete mpMatcher; + mpMatcher = new SfxFilterMatcher( SfxObjectShell::GetServiceNameFromFactory(rFactory) ); mbDeleteMatcher = sal_True; } @@ -1783,6 +1786,9 @@ void FileDialogHelper_Impl::addFilters( const String& rFactory, if ( ! xFltMgr.is() ) return; + if (mbDeleteMatcher) + delete mpMatcher; + // we still need a matcher to convert UI names to filter names if ( !rFactory.Len() ) { -- cgit