fix memory leak in wxFileTypeImpl::SetCommand() if creating the association fails
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45158 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1425,13 +1425,26 @@ wxFileTypeImpl::SetCommand(const wxString& cmd,
|
|||||||
wxMimeTypeCommands *entry = new wxMimeTypeCommands();
|
wxMimeTypeCommands *entry = new wxMimeTypeCommands();
|
||||||
entry->Add(verb + wxT("=") + cmd + wxT(" %s "));
|
entry->Add(verb + wxT("=") + cmd + wxT(" %s "));
|
||||||
|
|
||||||
bool ok = true;
|
bool ok = false;
|
||||||
size_t nCount = strTypes.GetCount();
|
size_t nCount = strTypes.GetCount();
|
||||||
for ( size_t i = 0; i < nCount; i++ )
|
for ( size_t i = 0; i < nCount; i++ )
|
||||||
{
|
{
|
||||||
if (!m_manager->DoAssociation(strTypes[i], strIcon, entry, strExtensions, strDesc))
|
if ( m_manager->DoAssociation
|
||||||
ok = false;
|
(
|
||||||
|
strTypes[i],
|
||||||
|
strIcon,
|
||||||
|
entry,
|
||||||
|
strExtensions,
|
||||||
|
strDesc
|
||||||
|
) )
|
||||||
|
{
|
||||||
|
// DoAssociation() took ownership of entry, don't delete it below
|
||||||
|
ok = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !ok )
|
||||||
|
delete entry;
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user