]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't crash if XRC file contains '_' at the end of a string.
authorVáclav Slavík <vslavik@fastmail.fm>
Sun, 15 Jan 2012 17:45:14 +0000 (17:45 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Sun, 15 Jan 2012 17:45:14 +0000 (17:45 +0000)
Parsing code for translating between '_' and '&' didn't properly handle
the case when the input was malformed and '_' wasn't followed by either
another '_' or another character. Added a check to guard against this.

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

src/xrc/xmlres.cpp
utils/wxrc/wxrc.cpp

index 0afbbcb58861528a2839163a5fad5d8b5e3d7cb3..55ae02d4d33d0b81a6c128df7ae0f29b11dfae19 100644 (file)
@@ -1554,7 +1554,7 @@ wxString wxXmlResourceHandler::GetText(const wxString& param, bool translate)
         // like "&File..." -- this is illegal in XML, so we use "_File..."):
         if ( *dt == amp_char )
         {
-            if ( *(++dt) == amp_char )
+            if ( dt+1 == str1.end() || *(++dt) == amp_char )
                 str2 << amp_char;
             else
                 str2 << wxT('&') << *dt;
index 9e580866c3f10880346955cb7e9e15df97f75b5d..1998c76687fdcdd2013ffa53a079e37fd8dfc07f 100644 (file)
@@ -896,7 +896,9 @@ static wxString ConvertText(const wxString& str)
     {
         if (*dt == wxT('_'))
         {
-            if ( *(++dt) == wxT('_') )
+            if ( *(dt+1) == 0 )
+                str2 << wxT('_');
+            else if ( *(++dt) == wxT('_') )
                 str2 << wxT('_');
             else
                 str2 << wxT('&') << *dt;