[Python-Dev] Bug in PyLocale_strcoll

Andreas Degert ad at papyrus-gmbh.de
Sat Nov 20 22:05:59 CET 2004


sorry to reply to my own post.. corrected patch following

--- _localemodule.c-2.49	Sat Nov 20 22:02:11 2004
+++ _localemodule.c	Sat Nov 20 22:01:48 2004
@@ -313,6 +313,7 @@
     }
     if (PyUnicode_AsWideChar((PyUnicodeObject*)os1, ws1, len1) == -1)
         goto done;
+    ws1[len1-1] = 0;
     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-Dev mailing list