]> git.saurik.com Git - wxWidgets.git/commitdiff
fix memory leak in wxFileTypeImpl::SetDefaultIcon() if creating the association fails
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 30 Mar 2007 16:10:30 +0000 (16:10 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 30 Mar 2007 16:10:30 +0000 (16:10 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45157 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/unix/mimetype.cpp

index 9aa4adaf07e89b71778203c43c9036a59f1c2dc5..76723ea65b42dc9085cb1e65f9c929b279505460 100644 (file)
@@ -1451,23 +1451,28 @@ bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int WXUNUSED(index)
         return false;
 
     wxMimeTypeCommands *entry = new wxMimeTypeCommands();
         return false;
 
     wxMimeTypeCommands *entry = new wxMimeTypeCommands();
-    bool ok = true;
+    bool ok = false;
     size_t nCount = strTypes.GetCount();
     for ( size_t i = 0; i < nCount; i++ )
     {
     size_t nCount = strTypes.GetCount();
     for ( size_t i = 0; i < nCount; i++ )
     {
-        if ( !m_manager->DoAssociation
-                         (
+        if ( m_manager->DoAssociation
+                        (
                             strTypes[i],
                             strIcon,
                             entry,
                             strExtensions,
                             strDesc
                             strTypes[i],
                             strIcon,
                             entry,
                             strExtensions,
                             strDesc
-                         ) )
+                        ) )
         {
         {
-            ok = false;
+            // we don't need to free entry now, DoAssociation() took ownership
+            // of it
+            ok = true;
         }
     }
 
         }
     }
 
+    if ( !ok )
+        delete entry;
+
     return ok;
 }
 
     return ok;
 }