From d9e89b159c80a704020efc7376b909893445f5e7 Mon Sep 17 00:00:00 2001 From: Ove Kaaven Date: Sat, 24 Apr 1999 12:21:03 +0000 Subject: [PATCH] cMB2WX and cWX2MB accepts null pointers. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2269 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/string.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/include/wx/string.h b/include/wx/string.h index 542bf06b12..d4f428f085 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -176,17 +176,21 @@ class WXDLLEXPORT wxMBConv virtual size_t WC2MB(char *buf, const wchar_t *psz, size_t n) const; const wxWCharBuffer cMB2WC(const char *psz) const { - size_t nLen = MB2WC((wchar_t *) NULL, psz, 0); - wxWCharBuffer buf(nLen); - MB2WC(WCSTRINGCAST buf, psz, nLen); - return buf; + if (psz) { + size_t nLen = MB2WC((wchar_t *) NULL, psz, 0); + wxWCharBuffer buf(nLen); + MB2WC(WCSTRINGCAST buf, psz, nLen); + return buf; + } else return wxWCharBuffer((wchar_t *) NULL); } const wxCharBuffer cWC2MB(const wchar_t *psz) const { - size_t nLen = WC2MB((char *) NULL, psz, 0); - wxCharBuffer buf(nLen); - WC2MB(MBSTRINGCAST buf, psz, nLen); - return buf; + if (psz) { + size_t nLen = WC2MB((char *) NULL, psz, 0); + wxCharBuffer buf(nLen); + WC2MB(MBSTRINGCAST buf, psz, nLen); + return buf; + } else return wxCharBuffer((char *) NULL); } #if wxUSE_UNICODE const wxWCharBuffer cMB2WX(const char *psz) const { return cMB2WC(psz); } -- 2.45.2