]> granicus.if.org Git - python/commitdiff
Make the prototypes of our private PyUnicode_FromWideChar and
authorThomas Heller <theller@ctypes.org>
Fri, 14 Jul 2006 15:01:05 +0000 (15:01 +0000)
committerThomas Heller <theller@ctypes.org>
Fri, 14 Jul 2006 15:01:05 +0000 (15:01 +0000)
PyUnicode_AsWideChar replacement functions compatible to the official
functions by using Py_ssize_t instead of int.

Modules/_ctypes/_ctypes.c
Modules/_ctypes/ctypes.h

index 2cbd5d593baa37a548e52496d2c577a7dad925bc..8090f5c79d9e0033a96861492a9b8655eba247b8 100644 (file)
@@ -4711,13 +4711,14 @@ init_ctypes(void)
 }
 
 /*****************************************************************
- * replacements for broken Python api functions
+ * replacements for broken Python api functions (in Python 2.3).
+ * See #1047269 Buffer overwrite in PyUnicode_AsWideChar
  */
 
 #ifdef HAVE_WCHAR_H
 
 PyObject *My_PyUnicode_FromWideChar(register const wchar_t *w,
-                                   int size)
+                                   Py_ssize_t size)
 {
     PyUnicodeObject *unicode;
 
@@ -4749,7 +4750,7 @@ PyObject *My_PyUnicode_FromWideChar(register const wchar_t *w,
 
 int My_PyUnicode_AsWideChar(PyUnicodeObject *unicode,
                            register wchar_t *w,
-                           int size)
+                           Py_ssize_t size)
 {
     if (unicode == NULL) {
        PyErr_BadInternalCall();
index 6db7015a423b764a06ee7690ebcd5294a37292b9..303eda31ec9c8a91f0ab7c09d78fa11e7e0b1872 100644 (file)
@@ -377,8 +377,8 @@ extern char *conversion_mode_errors;
 #  undef PyUnicode_AsWideChar
 #  define PyUnicode_AsWideChar My_PyUnicode_AsWideChar
 
-extern PyObject *My_PyUnicode_FromWideChar(const wchar_t *, int);
-extern int My_PyUnicode_AsWideChar(PyUnicodeObject *, wchar_t *, int);
+extern PyObject *My_PyUnicode_FromWideChar(const wchar_t *, Py_ssize_t);
+extern int My_PyUnicode_AsWideChar(PyUnicodeObject *, wchar_t *, Py_ssize_t);
 
 #endif