[PyObjC-svn] r2592 - trunk/pyobjc/pyobjc-core/Modules/objc

[email protected] Wed, 08 Sep 2010 10:09:31 -0500
Newsgroups gmane.comp.python.pyobjc.cvs
Message-ID <[email protected]>
Author: ronaldoussoren
Date: Wed Sep  8 10:09:30 2010
New Revision: 2592

Log:
Ensure that the pyobjc_unicode's internal storage is NUL terminated, 
some C extensions expect them to be.


Modified:
   trunk/pyobjc/pyobjc-core/Modules/objc/unicode-object.m

Modified: trunk/pyobjc/pyobjc-core/Modules/objc/unicode-object.m
==============================================================================
--- trunk/pyobjc/pyobjc-core/Modules/objc/unicode-object.m	(original)
+++ trunk/pyobjc/pyobjc-core/Modules/objc/unicode-object.m	Wed Sep  8 10:09:30 2010
@@ -227,7 +227,7 @@
 	 *  		NSArray.alloc().init()
 	 */
 	PyObjCUnicodeObject* result;
-// XXX - I don't know how to get gcc to let me use sizeof(unichar)
+
 #ifdef PyObjC_UNICODE_FAST_PATH
 	Py_ssize_t length = [value length];
 
@@ -237,6 +237,7 @@
 	}
 	result = PyObject_New(PyObjCUnicodeObject, &PyObjCUnicode_Type);
 	Py_UNICODE* tptr = PyObject_MALLOC(sizeof(Py_UNICODE) * (length+1));
+	tptr[0] = tptr[length] = 0;
 	result->base.str = tptr;
 	/*PyUnicode_AS_UNICODE(result) = tptr;*/
 	tptr = NULL;

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd