]> granicus.if.org Git - python/commitdiff
Fix some Py_ssize_t issues
authorNeal Norwitz <nnorwitz@gmail.com>
Mon, 12 Jun 2006 02:06:42 +0000 (02:06 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Mon, 12 Jun 2006 02:06:42 +0000 (02:06 +0000)
Modules/_tkinter.c
Modules/bz2module.c
Modules/dlmodule.c

index 0f6382efc7696ad113847b3e0f58b91bbda0a129..ee9a63369236b6be99f2ec33e3d2d7199a7a309c 100644 (file)
@@ -932,12 +932,13 @@ AsObj(PyObject *value)
 #ifdef Py_USING_UNICODE
        else if (PyUnicode_Check(value)) {
                Py_UNICODE *inbuf = PyUnicode_AS_UNICODE(value);
-               int size = PyUnicode_GET_SIZE(value);
+               Py_ssize_t size = PyUnicode_GET_SIZE(value);
                /* This #ifdef assumes that Tcl uses UCS-2.
                   See TCL_UTF_MAX test above. */
 #if defined(Py_UNICODE_WIDE) && TCL_UTF_MAX == 3
                Tcl_UniChar *outbuf;
-               int i;
+               Py_ssize_t i;
+               assert(size < size * sizeof(Tcl_UniChar));
                outbuf = (Tcl_UniChar*)ckalloc(size * sizeof(Tcl_UniChar));
                if (!outbuf) {
                        PyErr_NoMemory();
index ed329b8a0f016b61de154e69e7f84a61774d8117..8f4e1d88f7fdcb4184190caeba183950c18e9da8 100644 (file)
@@ -1570,7 +1570,7 @@ BZ2Comp_compress(BZ2CompObject *self, PyObject *args)
                }
        }
 
-       _PyString_Resize(&ret, (int)(BZS_TOTAL_OUT(bzs) - totalout));
+       _PyString_Resize(&ret, (Py_ssize_t)(BZS_TOTAL_OUT(bzs) - totalout));
 
        RELEASE_LOCK(self);
        return ret;
@@ -1636,7 +1636,7 @@ BZ2Comp_flush(BZ2CompObject *self)
        }
 
        if (bzs->avail_out != 0)
-               _PyString_Resize(&ret, (int)(BZS_TOTAL_OUT(bzs) - totalout));
+               _PyString_Resize(&ret, (Py_ssize_t)(BZS_TOTAL_OUT(bzs) - totalout));
 
        RELEASE_LOCK(self);
        return ret;
@@ -1860,7 +1860,7 @@ BZ2Decomp_decompress(BZ2DecompObject *self, PyObject *args)
        }
 
        if (bzs->avail_out != 0)
-               _PyString_Resize(&ret, (int)(BZS_TOTAL_OUT(bzs) - totalout));
+               _PyString_Resize(&ret, (Py_ssize_t)(BZS_TOTAL_OUT(bzs) - totalout));
 
        RELEASE_LOCK(self);
        return ret;
@@ -2069,7 +2069,7 @@ bz2_compress(PyObject *self, PyObject *args, PyObject *kwargs)
        }
 
        if (bzs->avail_out != 0)
-               _PyString_Resize(&ret, (int)BZS_TOTAL_OUT(bzs));
+               _PyString_Resize(&ret, (Py_ssize_t)BZS_TOTAL_OUT(bzs));
        BZ2_bzCompressEnd(bzs);
 
        return ret;
@@ -2148,7 +2148,7 @@ bz2_decompress(PyObject *self, PyObject *args)
        }
 
        if (bzs->avail_out != 0)
-               _PyString_Resize(&ret, (int)BZS_TOTAL_OUT(bzs));
+               _PyString_Resize(&ret, (Py_ssize_t)BZS_TOTAL_OUT(bzs));
        BZ2_bzDecompressEnd(bzs);
 
        return ret;
index 09556814f2dc779e7e397ca1745416c7de0f1847..899ad866cfc94762008744146cb8a0107e072d2b 100644 (file)
@@ -77,8 +77,8 @@ dl_call(dlobject *xp, PyObject *args)
                      long, long, long, long, long);
        long alist[10];
        long res;
-       int i;
-       int n = PyTuple_Size(args);
+       Py_ssize_t i;
+       Py_ssize_t n = PyTuple_Size(args);
        if (n < 1) {
                PyErr_SetString(PyExc_TypeError, "at least a name is needed");
                return NULL;