[Python-checkins] python/dist/src/Modules _localemodule.c, 2.49, 2.50

lemburg at users.sourceforge.net lemburg at users.sourceforge.net
Mon Nov 22 14:02:32 CET 2004


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv780/Modules
Modified Files:
	_localemodule.c 
Log Message:
Correct the handling of 0-termination of PyUnicode_AsWideChar() 
and its usage in PyLocale_strcoll().
Clarify the documentation on this.
Thanks to Andreas Degert for pointing this out.
Index: _localemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v
retrieving revision 2.49
retrieving revision 2.50
diff -u -d -r2.49 -r2.50
--- _localemodule.c	27 Aug 2004 05:00:22 -0000	2.49
+++ _localemodule.c	22 Nov 2004 13:02:30 -0000	2.50
@@ -305,7 +305,6 @@
 }
 /* Convert the unicode strings to wchar[]. */
 len1 = PyUnicode_GET_SIZE(os1) + 1;
- len2 = PyUnicode_GET_SIZE(os2) + 1;
 ws1 = PyMem_MALLOC(len1 * sizeof(wchar_t));
 if (!ws1) {
 PyErr_NoMemory();
@@ -313,6 +312,8 @@
 }
 if (PyUnicode_AsWideChar((PyUnicodeObject*)os1, ws1, len1) == -1)
 goto done;
+ ws1[len1 - 1] = 0;
+ len2 = PyUnicode_GET_SIZE(os2) + 1;
 ws2 = PyMem_MALLOC(len2 * sizeof(wchar_t));
 if (!ws2) {
 PyErr_NoMemory();
@@ -320,6 +321,7 @@
 }
 if (PyUnicode_AsWideChar((PyUnicodeObject*)os2, ws2, len2) == -1)
 goto done;
+ ws2[len2 - 1] = 0;
 /* Collate the strings. */
 result = PyInt_FromLong(wcscoll(ws1, ws2));
 done:


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /