From 76b0f8384ed211c5f6b48597a62da743b604e666 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 11 Sep 2013 15:06:04 +0000 Subject: [PATCH] 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 --- src/generic/dcpsg.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index d14255fd08..1fcc3611fa 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -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) { -- 2.45.2