fix memory leak in wxFileTypeImpl::SetDefaultIcon() if creating the association fails

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45157 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2007-03-30 16:10:30 +00:00
parent 82c91ef51f
commit 2f769cb93b

View File

@ -1451,23 +1451,28 @@ bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int WXUNUSED(index)
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++ )
{
if ( !m_manager->DoAssociation
(
if ( m_manager->DoAssociation
(
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;
}