[wx-dev] [ wxwindows-Bugs-1955413 ] wxString::To8BitData segfaults for apostrophe character

SourceForge.net noreply at sourceforge.net
Thu May 1 13:30:21 PDT 2008


Bugs item #1955413, was opened at 2008-05-01 15:19
Message generated for change (Settings changed) made by vaclavslavik
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1955413&group_id=9863

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Generic
Group: Must fix
Status: Closed
>Resolution: Invalid
Priority: 5
Private: No
Submitted By: Andrej Sinicyn (andrej4000)
Assigned to: Nobody/Anonymous (nobody)
Summary: wxString::To8BitData segfaults for apostrophe character

Initial Comment:
If I have a Unicode string containing the punctuation apostrophe (U+2019) and try to convert it to ANSI the whole program segfaults.

I'm using Unicode builds of wxGTK and wxMSW and both have the problem.

----------------------------------------------------------------------

Comment By: Andrej Sinicyn (andrej4000)
Date: 2008-05-01 20:20

Message:
Logged In: YES 
user_id=508463
Originator: YES

I thought that To8BitData() is just a call of mb_str defaulting to
ISO-8859-1 (That's what I in fact need, not ANSI).

I'm using v2.8.7, there wasn't a backtrace, a patch isn't yet needed as I
investigated further.
The segfault resultied in writing of an empty string to a socket.

Indeed To8BitData returns an empty string, if the input conatinas any
non-ISO-8859-1 chars, so using wxEncodingConverter explicitely before
solves the problem

----------------------------------------------------------------------

Comment By: Vaclav Slavik (vaclavslavik)
Date: 2008-05-01 15:29

Message:
Logged In: YES 
user_id=80834
Originator: NO

Your forgot to include three crucial pieces of information:

(1) wx version
(2) backtrace showing where exactly the crash occurred
(3) a patch against one of the wx samples or a small program that can be
used to reproduce the bug

Changes are high that it's a bug in the code _using_ To8BitData().

> try to convert it to ANSI

Note that this method is *not* appropriate for converting to ANSI,
mb_str() is. To8BitData() is intended *only* for retrieval of strings
previously set using From8BitData() in cases when you need to store
non-string binary data in wxString, it's not meant for anything else.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1955413&group_id=9863


More information about the wx-dev mailing list