SWIG_AsWCharPtrAndSize improper operation if cptr NULL

SF bug #1327

This doesn't have any noticeable effect with the usage of
SWIG_AsWCharPtrAndSize as shipped by SWIG, but could be a problem if a
user is using this function with cptr equal to zero and psize is non-zero
 - the length would be incorrectly set due to the call to PyUnicode_GetSize
failing.
This commit is contained in:
William S Fulton 2013-07-02 18:47:00 +01:00
commit ace8fcd972
3 changed files with 15 additions and 3 deletions

View file

@ -18,9 +18,7 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc)
int isunicode = PyUnicode_Check(obj);
%#if PY_VERSION_HEX < 0x03000000
if (!isunicode && PyString_Check(obj)) {
if (cptr) {
obj = tmp = PyUnicode_FromObject(obj);
}
obj = tmp = PyUnicode_FromObject(obj);
isunicode = 1;
}
%#endif