Commits

Anonymous committed 0b2c285

Fixed integer color value assignment bound checking in PixelArray as reported by andre_pl.

  • Participants
  • Parent commits 9799aeb

Comments (0)

Files changed (1)

File src/pixelarray.c

 
     if (PyInt_Check (val))
     {
-        int intval = PyInt_AsLong (val);
-        if (intval < 0)
+        long intval = PyInt_AsLong (val);
+        if ((intval < INT_MIN) || (intval > INT_MAX))
         {
             if (!PyErr_Occurred ())
                 PyErr_SetString (PyExc_ValueError, "invalid color argument");
     }
     else if (PyLong_Check (val))
     {
-        long long longval = -1;
-        /* Plain index: array[x, */
-
-        longval = PyLong_AsLong (val);
+        long long longval = PyLong_AsLong (val);
         if ((longval < INT_MIN) || (longval > INT_MAX))
         {
-            PyErr_SetString(PyExc_ValueError,
-                "index too big for array access");
+            PyErr_SetString(PyExc_ValueError, "invalid color argument");
             return 0;
         }
         *color = (Uint32) longval;