X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2f769cb93b946bf1ba33eac7af67aa43b42f72aa..9859d369b49e35a1cad0f760173e165f974fb6cb:/src/unix/mimetype.cpp diff --git a/src/unix/mimetype.cpp b/src/unix/mimetype.cpp index 76723ea65b..a1b56f14d6 100644 --- a/src/unix/mimetype.cpp +++ b/src/unix/mimetype.cpp @@ -1425,14 +1425,27 @@ wxFileTypeImpl::SetCommand(const wxString& cmd, wxMimeTypeCommands *entry = new wxMimeTypeCommands(); entry->Add(verb + wxT("=") + cmd + wxT(" %s ")); - bool ok = true; + bool ok = false; size_t nCount = strTypes.GetCount(); for ( size_t i = 0; i < nCount; i++ ) { - if (!m_manager->DoAssociation(strTypes[i], strIcon, entry, strExtensions, strDesc)) - ok = false; + if ( m_manager->DoAssociation + ( + strTypes[i], + strIcon, + entry, + strExtensions, + strDesc + ) ) + { + // DoAssociation() took ownership of entry, don't delete it below + ok = true; + } } + if ( !ok ) + delete entry; + return ok; }