Don't crash if XRC file contains '_' at the end of a string.

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
This commit is contained in:
Václav Slavík
2012-01-15 17:45:14 +00:00
parent 9c71750d80
commit 2148394afb
2 changed files with 4 additions and 2 deletions

View 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;

View 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;