fix for potential crash when conversion fails

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39886 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2006-06-29 08:16:49 +00:00
parent 1ae82ba9f2
commit a0ef88bde8

View File

@@ -1782,6 +1782,13 @@ bool wxDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) con
#endif
{
wxCharBuffer buff = text.mb_str(wxConvLocal);
if ( buff.data() == 0 )
{
for (size_t i=0; i<text.length(); i++)
widths[i] = 0 ;
}
else
{
size_t len = strlen(buff);
short* measurements = new short[len+1];
MeasureText(len, buff.data(), measurements);
@@ -1794,6 +1801,7 @@ bool wxDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) con
delete [] measurements;
}
}
return true;
}