Segfault in wxMBConvUTF8::MB2WC on startup

From: gson(at)araneus(dot)fi (Andreas Gustafsson)
To: pgadmin-support(at)postgresql(dot)org
Cc: thomasklausner(at)users(dot)sourceforge(dot)net, dan(at)langille(dot)org
Subject: Segfault in wxMBConvUTF8::MB2WC on startup
Date: 2005-10-06 14:09:22
Message-ID: 17221.12306.903030.125929@guava.araneus.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

I built pgadmin3 1.2.1 with wkGTK-2.6.2 on NetBSD/i386 2.0_BETA by
means of pkgsrc-wip, but the resulting binary segfaults on startup:

Program received signal SIGSEGV, Segmentation fault.
0x48a47178 in wxMBConvUTF8::MB2WC(wchar_t*, char const*, unsigned) const () from /usr/pkg/lib/libwx_base-2.6.so
(gdb) where
#0 0x48a47178 in wxMBConvUTF8::MB2WC(wchar_t*, char const*, unsigned) const () from /usr/pkg/lib/libwx_base-2.6.so
#1 0x0819bb82 in wxUtfFile::Read(wxString&, long long) (this=0xbfbff500, str=(at)0xbfbff530, nCount=1654) at utils/utffile.cpp:92
#2 0x08194f8a in FileRead(wxString const&, int) (filename=(at)0xbfbff6e0, format=1) at utils/misc.cpp:482
#3 0x08065a6a in pgAdmin3::OnInit() (this=0x830a980) at pgAdmin3.cpp:228
#4 0x08066ee4 in wxAppConsole::CallOnInit() (this=0x830a980)
at /usr/pkgsrc/wip/pgadmin3/work/.buildlink/include/wx-2.6/wx/app.h:87
#5 0x48a2c13c in wxEntry(int&, char**) () from /usr/pkg/lib/libwx_base-2.6.so
#6 0x080651f1 in main (argc=1, argv=0xbfbff83c) at pgAdmin3.cpp:81
#7 0x08064ef2 in ___start ()

This looks like the same crash as that reported in
<http://lists.freebsd.org/pipermail/freebsd-ports/2005-January/019694.html>
The following patch appears to fix the problem. Is it the correct fix?

--- utffile.cpp.old 2005-10-06 16:49:28.000000000 +0300
+++ utffile.cpp 2005-10-06 16:28:09.000000000 +0300
@@ -89,7 +89,8 @@
if (decr)
Seek(-decr, wxFromCurrent);

- m_conversion->MB2WC((wchar_t*)(wxChar*)wxStringBuffer(str, nLen+1), (const char*)buffer, (size_t)(nLen+1));
+ m_conversion->MB2WC((wchar_t*)(wxChar*)wxStringBuffer(str, (nLen+1) * sizeof(wchar_t)),
+ (const char*)buffer, (size_t)(nLen+1));
}
else
str = (wxChar*)buffer;

--
Andreas Gustafsson, gson(at)araneus(dot)fi

Responses

Browse pgadmin-support by date

  From Date Subject
Next Message Dave Page 2005-10-07 10:57:58 Re: Crash when opening table properties
Previous Message Walter Haslbeck 2005-10-06 06:55:04 Re: Crash when opening table properties