From: Vadim Zeitlin Date: Wed, 6 Apr 2011 14:37:36 +0000 (+0000) Subject: Avoid dereferencing invalid iterator in wxMessageDialog code. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/3672f9d04dbb1d8ee758e5f326c36b43cf5f69f8?ds=inline Avoid dereferencing invalid iterator in wxMessageDialog code. 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 --- diff --git a/src/msw/msgdlg.cpp b/src/msw/msgdlg.cpp index 8ea5e5e5f0..c66806fee4 100644 --- a/src/msw/msgdlg.cpp +++ b/src/msw/msgdlg.cpp @@ -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; } }