On Wed, Mar 06, 2013 at 07:35:26AM +1100, Kevin Ryde wrote: > gdb claims it to be in wxPostScriptDC::DoGetTextExtent() dcpsg.cpp line > 2151 and has p==NULL. If my sources are up-to-date that line would be > > for(p=(unsigned char *)wxMBSTRINGCAST strbuf; *p; p++) > > Maybe it's something locale related. If I make a utf8 and switch to it > like LC_ALL=en_US.UTF-8 then the print works. In that case it warns too > that I don't have file /usr/share/wx/gs_afm/Helv.afm, if that makes a > difference. > > Is that p strbuf thing a conversion to a locale string to measure the > characters or something? Dunno what it should do if the locale is not > enough for the string to be printed, but you'd hope it didn't crash.
I forwarded the bug upstream, who suggested just returning in this case, and I came up with the attached patch which implements that. My unstable chroot seems to have got in an odd state, so I haven't tried building it yet, but if you have the setup to hand to reproduce the issue, please give it a go and let me know if it fixes it. Cheers, Olly
diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index e2eadde..ce32934 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -2147,8 +2147,20 @@ void wxPostScriptDC::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) {