mirror of https://github.com/python/cpython
(The fix has been slightly adjusted.)
Merged revisions 69505 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r69505 | thomas.heller | 2009-02-10 19:43:01 +0100 (Di, 10 Feb 2009) | 3 lines Issue#5203: ctypes segfaults when passing a unicode string to a function without argtypes, if HAVE_USABLE_WCHAR_T is false. ........
This commit is contained in:
parent
a06f44b143
commit
465c802044
|
@ -163,6 +163,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #5203: Fixed ctypes segfaults when passing a unicode string to a
|
||||||
|
function without argtypes (only occurs if HAVE_USABLE_WCHAR_T is false).
|
||||||
|
|
||||||
- Issue #3386: distutils.sysconfig.get_python_lib prefix argument was ignored
|
- Issue #3386: distutils.sysconfig.get_python_lib prefix argument was ignored
|
||||||
under NT and OS2. Patch by Philip Jenvey.
|
under NT and OS2. Patch by Philip Jenvey.
|
||||||
|
|
||||||
|
|
|
@ -645,14 +645,15 @@ static int ConvParam(PyObject *obj, Py_ssize_t index, struct argument *pa)
|
||||||
|
|
||||||
#ifdef CTYPES_UNICODE
|
#ifdef CTYPES_UNICODE
|
||||||
if (PyUnicode_Check(obj)) {
|
if (PyUnicode_Check(obj)) {
|
||||||
pa->ffi_type = &ffi_type_pointer;
|
|
||||||
#ifdef HAVE_USABLE_WCHAR_T
|
#ifdef HAVE_USABLE_WCHAR_T
|
||||||
|
pa->ffi_type = &ffi_type_pointer;
|
||||||
pa->value.p = PyUnicode_AS_UNICODE(obj);
|
pa->value.p = PyUnicode_AS_UNICODE(obj);
|
||||||
Py_INCREF(obj);
|
Py_INCREF(obj);
|
||||||
pa->keep = obj;
|
pa->keep = obj;
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
int size = PyUnicode_GET_SIZE(obj);
|
int size = PyUnicode_GET_SIZE(obj);
|
||||||
|
pa->ffi_type = &ffi_type_pointer;
|
||||||
size += 1; /* terminating NUL */
|
size += 1; /* terminating NUL */
|
||||||
size *= sizeof(wchar_t);
|
size *= sizeof(wchar_t);
|
||||||
pa->value.p = PyMem_Malloc(size);
|
pa->value.p = PyMem_Malloc(size);
|
||||||
|
|
Loading…
Reference in New Issue