Fix undefined behavior sometimes resulting in a crash when copying styles to or from storage when the style name already exists. Patch by Paranoja. Closes #1096.

Originally committed to SVN as r3961.
This commit is contained in:
Thomas Goyne 2010-01-07 00:48:27 +00:00
parent a1902a0690
commit 8657658c70
1 changed files with 2 additions and 2 deletions

View File

@ -601,7 +601,7 @@ void DialogStyleManager::OnCopyToStorage (wxCommandEvent &event) {
for (std::list<AssStyle *>::iterator style = Store.style.begin(); style != Store.style.end(); ++style) {
if ((*style)->name.CmpNoCase(styleName) == 0) {
addStyle = false;
if (wxYES == wxMessageBox(wxString::Format(_T("There is already a style with the name \"%s\" on the current storage. Proceed and overwrite anyway?"),styleName), _T("Style name collision."), wxYES_NO)) {
if (wxYES == wxMessageBox(wxString::Format(_T("There is already a style with the name \"%s\" on the current storage. Proceed and overwrite anyway?"),styleName.c_str()), _T("Style name collision."), wxYES_NO)) {
**style = *styleMap.at(selections[i]);
}
break;
@ -632,7 +632,7 @@ void DialogStyleManager::OnCopyToCurrent (wxCommandEvent &event) {
for (std::vector<AssStyle *>::iterator style = styleMap.begin(); style != styleMap.end(); ++style) {
if ((*style)->name.CmpNoCase(styleName) == 0) {
addStyle = false;
if (wxYES == wxMessageBox(wxString::Format(_T("There is already a style with the name \"%s\" on the current script. Proceed and overwrite anyway?"),styleName), _T("Style name collision."), wxYES_NO)) {
if (wxYES == wxMessageBox(wxString::Format(_T("There is already a style with the name \"%s\" on the current script. Proceed and overwrite anyway?"),styleName.c_str()), _T("Style name collision."), wxYES_NO)) {
**style = *styleStorageMap.at(selections[i]);
}
break;