From d3019e4d0a0730c31ba7ab64e0f80ac44e6ecc8a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 3 Feb 2010 21:07:38 +0000 Subject: [PATCH] Fix bug in wxMSW wxMessageDialog when the text was empty. Don't crash in ReplaceStaticWithEdit() dereferencing an invalid end()-1 iterator in this case, use the always valid rbegin() instead. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63377 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/msgdlg.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/msw/msgdlg.cpp b/src/msw/msgdlg.cpp index 108beb7d1b..d0ddb15ac0 100644 --- a/src/msw/msgdlg.cpp +++ b/src/msw/msgdlg.cpp @@ -246,11 +246,12 @@ void wxMessageDialog::ReplaceStaticWithEdit() // ignored by the static control but result in extra lines and hence extra // scrollbar position in the edit one wxString text(wxGetWindowText(hwndStatic)); - for ( wxString::iterator i = text.end() - 1; i != text.begin(); --i ) + for ( wxString::reverse_iterator i = text.rbegin(); i != text.rend(); ++i ) { if ( *i != '\n' ) { - text.erase(i + 1, text.end()); + // found last non-newline char, remove everything after it and stop + text.erase(i.base() + 1, text.end()); break; } } -- 2.45.2