From d6d52920ec2f8c5d2ae74a219d16d211ecf45af9 Mon Sep 17 00:00:00 2001 From: Andrew de los Reyes Date: Fri, 16 Mar 2012 21:08:27 -0700 Subject: [PATCH] Fix segfault in LogWindow on Mac Commit 9ddb67d4a96a53698a71a7f3c8936c2437dd81de 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. --- Source/Core/DolphinWX/Src/LogWindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinWX/Src/LogWindow.cpp b/Source/Core/DolphinWX/Src/LogWindow.cpp index 0d11ef0142..4c9c495713 100644 --- a/Source/Core/DolphinWX/Src/LogWindow.cpp +++ b/Source/Core/DolphinWX/Src/LogWindow.cpp @@ -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)