File Imaging-1.1.7-ssize.patch of Package python-imaging

Index: _imaging.c
===================================================================
--- _imaging.c.orig
+++ _imaging.c
@@ -369,6 +369,7 @@ static void*
 getlist(PyObject* arg, int* length, const char* wrong_length, int type)
 {
     int i, n;
+    Py_ssize_t s;
     void* list;
 
     if (!PySequence_Check(arg)) {
@@ -376,7 +377,8 @@ getlist(PyObject* arg, int* length, cons
 	return NULL;
     }
 
-    n = PyObject_Length(arg);
+    s = PyObject_Length(arg);
+    n = (s > INT_MAX) ? INT_MAX : s;
     if (length && wrong_length && n != *length) {
 	PyErr_SetString(PyExc_ValueError, wrong_length);
 	return NULL;
@@ -1204,6 +1206,7 @@ _putdata(ImagingObject* self, PyObject*
 {
     Imaging image;
     int n, i, x, y;
+    Py_ssize_t s;
 
     PyObject* data;
     double scale = 1.0;
@@ -1218,7 +1221,8 @@ _putdata(ImagingObject* self, PyObject*
 
     image = self->image;
 
-    n = PyObject_Length(data);
+    s = PyObject_Length(data);
+    n = (s > INT_MAX) ? INT_MAX : s;
     if (n > (int) (image->xsize * image->ysize)) {
 	PyErr_SetString(PyExc_TypeError, "too many data entries");
 	return NULL;
@@ -3014,7 +3018,7 @@ image_item(ImagingObject *self, Py_ssize
 }
 
 static PySequenceMethods image_as_sequence = {
-    (inquiry) image_length, /*sq_length*/
+    (lenfunc) image_length, /*sq_length*/
     (binaryfunc) NULL, /*sq_concat*/
     (ssizeargfunc) NULL, /*sq_repeat*/
     (ssizeargfunc) image_item, /*sq_item*/
Index: path.c
===================================================================
--- path.c.orig
+++ path.c
@@ -116,6 +116,7 @@ int
 PyPath_Flatten(PyObject* data, double **pxy)
 {
     int i, j, n;
+    Py_ssize_t s;
     double *xy;
 
     if (PyPath_Check(data)) {
@@ -149,7 +150,8 @@ PyPath_Flatten(PyObject* data, double **
     }
 
     j = 0;
-    n = PyObject_Length(data);
+    s = PyObject_Length(data);
+    n = (s > INT_MAX) ? INT_MAX : s;
     /* Just in case __len__ breaks (or doesn't exist) */
     if (PyErr_Occurred())
         return -1;
@@ -359,7 +361,7 @@ path_getbbox(PyPathObject* self, PyObjec
 }
 
 static PyObject*
-path_getitem(PyPathObject* self, int i)
+path_getitem(PyPathObject* self, Py_ssize_t i)
 {
     if (i < 0 || i >= self->count) {
 	PyErr_SetString(PyExc_IndexError, "path index out of range");
@@ -425,7 +427,7 @@ path_map(PyPathObject* self, PyObject* a
 }
 
 static int
-path_setitem(PyPathObject* self, int i, PyObject* op)
+path_setitem(PyPathObject* self, Py_ssize_t i, PyObject* op)
 {
     double* xy;
 
openSUSE Build Service is sponsored by