Commits

Anonymous committed 9f4efe3

Fixed memory leaks in pygame2.sdlext.PixelArray subscript methods.

Comments (0)

Files changed (2)

src/sdlext/pixelarray.c

             return NULL;
         /* A simple index. */
         i = PyNumber_AsSsize_t (val, PyExc_IndexError);
+        Py_DECREF (val);
 #else
         if (PyInt_Check (op))
             i = PyInt_AsLong (op);
             return -1;
         /* A simple index. */
         i = PyNumber_AsSsize_t (val, PyExc_IndexError);
+        Py_DECREF (val);
 #else
         if (PyInt_Check (op))
             i = PyInt_AsLong (op);

src/sdlext/pixelarray_methods.c

         for (i = 0; i < 3; i++)
         {
             item = PySequence_ITEM (weights, i);
-            if (PyNumber_Check (item))
+            if (item && PyNumber_Check (item))
             {
                 PyObject *num = NULL;
                 if ((num = PyNumber_Float (item)) != NULL)