Fix another crash when conversion fails in Unix PostScript code.

Returning 0 length from GetTextExtent() is hardly ideal but it's better than
crashing.

Closes #15489.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74786 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2013-09-11 15:06:04 +00:00
parent 58abb2327c
commit 76b0f8384e

View File

@ -2339,8 +2339,20 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string,
long sum=0;
float height=fontSize; /* by default */
unsigned char *p;
for(p=(unsigned char *)wxMBSTRINGCAST strbuf; *p; p++)
unsigned char *p=(unsigned char *)wxMBSTRINGCAST strbuf;
if(!p)
{
// String couldn't be converted which used to SEGV as reported here:
// http://bugs.debian.org/702378
// http://trac.wxwidgets.org/ticket/15300
// Upstream suggests "just return if the conversion failed".
if (x) (*x) = 0;
if (y) (*y) = 0;
if (descent) (*descent) = 0;
if (externalLeading) (*externalLeading) = 0;
return;
}
for(; *p; p++)
{
if(lastWidths[*p]== INT_MIN)
{