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:
@@ -1782,6 +1782,13 @@ bool wxDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) con
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
wxCharBuffer buff = text.mb_str(wxConvLocal);
|
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);
|
size_t len = strlen(buff);
|
||||||
short* measurements = new short[len+1];
|
short* measurements = new short[len+1];
|
||||||
MeasureText(len, buff.data(), measurements);
|
MeasureText(len, buff.data(), measurements);
|
||||||
@@ -1794,6 +1801,7 @@ bool wxDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) con
|
|||||||
|
|
||||||
delete [] measurements;
|
delete [] measurements;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user