]> git.saurik.com Git - wxWidgets.git/commitdiff
Avoid dereferencing invalid iterator in wxMessageDialog code.
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 6 Apr 2011 14:37:36 +0000 (14:37 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 6 Apr 2011 14:37:36 +0000 (14:37 +0000)
The iterator wxString::rbegin().base()+1 is invalid so check that we don't use
it.

Closes #13126.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67407 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/msgdlg.cpp

index 8ea5e5e5f01dd722777c5be060e91e3e7f7391e6..c66806fee474ccec15afd010e18f13c4bfb07714 100644 (file)
@@ -253,8 +253,10 @@ void wxMessageDialog::ReplaceStaticWithEdit()
     {
         if ( *i != '\n' )
         {
-            // found last non-newline char, remove everything after it and stop
-            text.erase(i.base() + 1, text.end());
+            // found last non-newline char, remove anything after it if
+            // necessary and stop in any case
+            if ( i != text.rbegin() )
+                text.erase(i.base() + 1, text.end());
             break;
         }
     }