From cfcfada96e76129a630ab9c47f346fbfc5e9de8d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 17 Oct 2010 13:59:42 +0000 Subject: [PATCH] Return valid buffer from wxMBConv::c{MB,WC}2{WC,MB} for empty input. Returning invalid buffer for empty input is unexpected and resulted in e.g. wxString::utf8_str() returning NULL and not "" in ANSI build for empty strings (which, in turn, resulted in crashes in the test suite and undoubtedly not only) as well as crashes when calling GTK+ functions (see #12432). Other uses of cMB2WC() also show that NULL return value from it is unexpected as it is often passed to CRT functions not accepting NULL. So return empty buffer instead for empty input to avoid all these problems. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65836 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/strconv.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index a58245815d..4615f5b24b 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -537,7 +537,7 @@ const wxWCharBuffer wxMBConv::cMB2WC(const wxScopedCharBuffer& buf) const } } - return wxWCharBuffer(); + return wxScopedWCharBuffer::CreateNonOwned(L"", 0); } const wxCharBuffer wxMBConv::cWC2MB(const wxScopedWCharBuffer& wbuf) const @@ -555,7 +555,7 @@ const wxCharBuffer wxMBConv::cWC2MB(const wxScopedWCharBuffer& wbuf) const } } - return wxCharBuffer(); + return wxScopedCharBuffer::CreateNonOwned("", 0); } // ----------------------------------------------------------------------------