From 170531ee4b95e65cdf9cdd9bb86cf032aca224ee Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 16 Jan 2003 03:30:18 +0000 Subject: [PATCH] Work around a bug (I think) in the Python API PyUnicode_AsWideChar when the length of the unicode object is zero. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@18759 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/src/helpers.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/wxPython/src/helpers.cpp b/wxPython/src/helpers.cpp index 33966b1331..721f22917d 100644 --- a/wxPython/src/helpers.cpp +++ b/wxPython/src/helpers.cpp @@ -1466,8 +1466,10 @@ wxString* wxString_in_helper(PyObject* source) { if (PyUnicode_Check(source)) { target = new wxString(); size_t len = PyUnicode_GET_SIZE(source); - PyUnicode_AsWideChar((PyUnicodeObject*)source, target->GetWriteBuf(len), len); - target->UngetWriteBuf(); + if (len) { + PyUnicode_AsWideChar((PyUnicodeObject*)source, target->GetWriteBuf(len), len); + target->UngetWriteBuf(); + } } else { // It is a string, get pointers to it and transform to unicode char* tmpPtr; int tmpSize; @@ -1510,8 +1512,10 @@ wxString Py2wxString(PyObject* source) #if wxUSE_UNICODE if (PyUnicode_Check(source)) { size_t len = PyUnicode_GET_SIZE(source); - PyUnicode_AsWideChar((PyUnicodeObject*)source, target.GetWriteBuf(len), len); - target.UngetWriteBuf(); + if (len) { + PyUnicode_AsWideChar((PyUnicodeObject*)source, target.GetWriteBuf(len), len); + target.UngetWriteBuf(); + } } else { // It is a string, get pointers to it and transform to unicode char* tmpPtr; int tmpSize;