Fix segfault in LogWindow on Mac

Commit 9ddb67d4a9 seems to have
introduced a segfault on Mac. The issue is that it this change casts
wxConvCurrent (which is a wxMBConvLibc) to a wxCSConv. This is an
unsafe cast because wxCSConv has member variables, but wxMBConvLibc
does not.

In LogWindow.cpp, the constructor for m_SJISConv is dereferencing one
of those member variables, which is a dereference of uninitialized
memory!

This CL reverts to the older (non-crashing) constructor, but keeps the
behavior the same.
This commit is contained in:
Andrew de los Reyes 2012-03-16 21:08:27 -07:00
parent ed3f9ce288
commit d6d52920ec

View File

@ -41,7 +41,7 @@ CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos,
, x(0), y(0), winpos(0)
, Parent(parent), m_ignoreLogTimer(false), m_LogAccess(true)
, m_Log(NULL), m_cmdline(NULL), m_FontChoice(NULL)
, m_SJISConv(*(wxCSConv*)wxConvCurrent)
, m_SJISConv(wxT(""))
{
#ifdef _WIN32
static bool validCP932 = ::IsValidCodePage(932) != 0;
@ -52,6 +52,7 @@ CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos,
else
{
WARN_LOG(COMMON, "Cannot Convert from Charset Windows Japanese cp 932");
m_SJISConv = *(wxCSConv*)wxConvCurrent;
}
#else
// on linux the wrong string is returned from wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS)