From: Ove Kaaven Date: Sun, 18 Apr 1999 10:48:43 +0000 (+0000) Subject: glibc2.1 chokes on null input to wcstombs() X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/923d3156955a0d040f0db70151a55edf8cb4f6f5 glibc2.1 chokes on null input to wcstombs() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2227 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/wxchar.cpp b/src/common/wxchar.cpp index a8cde061fb..68acc24013 100644 --- a/src/common/wxchar.cpp +++ b/src/common/wxchar.cpp @@ -42,6 +42,10 @@ size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n) { if (buf) { + if (!n || !*psz) { + if (n) *buf = _T('\0'); + return 0; + } return mbstowcs(buf, psz, n); } @@ -60,6 +64,11 @@ size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n) size_t wxWC2MB(char *buf, const wchar_t *pwz, size_t n) { if (buf) { + if (!n || !*pwz) { + // glibc2.1 chokes on null input + if (n) *buf = '\0'; + return 0; + } return wcstombs(buf, pwz, n); }