[Python-checkins] r69508 - in python/branches/release30-maint: Misc/NEWS Modules/_ctypes/callproc.c

thomas.heller python-checkins at python.org
Tue Feb 10 20:04:16 CET 2009


Author: thomas.heller
Date: Tue Feb 10 20:04:16 2009
New Revision: 69508

Log:
Merged revisions 69507 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r69507 | thomas.heller | 2009-02-10 19:59:04 +0100 (Di, 10 Feb 2009) | 13 lines
  
  (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.
  ........
................


Modified:
   python/branches/release30-maint/   (props changed)
   python/branches/release30-maint/Misc/NEWS
   python/branches/release30-maint/Modules/_ctypes/callproc.c

Modified: python/branches/release30-maint/Misc/NEWS
==============================================================================
--- python/branches/release30-maint/Misc/NEWS	(original)
+++ python/branches/release30-maint/Misc/NEWS	Tue Feb 10 20:04:16 2009
@@ -116,6 +116,9 @@
 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
   under NT and OS2. Patch by Philip Jenvey.
 

Modified: python/branches/release30-maint/Modules/_ctypes/callproc.c
==============================================================================
--- python/branches/release30-maint/Modules/_ctypes/callproc.c	(original)
+++ python/branches/release30-maint/Modules/_ctypes/callproc.c	Tue Feb 10 20:04:16 2009
@@ -645,14 +645,15 @@
 
 #ifdef CTYPES_UNICODE
 	if (PyUnicode_Check(obj)) {
-		pa->ffi_type = &ffi_type_pointer;
 #ifdef HAVE_USABLE_WCHAR_T
+		pa->ffi_type = &ffi_type_pointer;
 		pa->value.p = PyUnicode_AS_UNICODE(obj);
 		Py_INCREF(obj);
 		pa->keep = obj;
 		return 0;
 #else
 		int size = PyUnicode_GET_SIZE(obj);
+		pa->ffi_type = &ffi_type_pointer;
 		size += 1; /* terminating NUL */
 		size *= sizeof(wchar_t);
 		pa->value.p = PyMem_Malloc(size);


More information about the Python-checkins mailing list