diff Python/bltinmodule.c @ 84846:de7e4fd634fb 3.3

Issue #18560: Fix potential NULL pointer dereference in sum()
author Christian Heimes <christian@cheimes.de>
date Fri, 26 Jul 2013 22:49:26 +0200
parents 4b3b87719e2c
children 4d62a62ba44d a5d9e2f3f6c7
line wrap: on
line diff
--- a/Python/bltinmodule.c	Fri Jul 26 22:45:00 2013 +0200
+++ b/Python/bltinmodule.c	Fri Jul 26 22:49:26 2013 +0200
@@ -2009,6 +2009,11 @@
             }
             /* Either overflowed or is not an int. Restore real objects and process normally */
             result = PyLong_FromLong(i_result);
+            if (result == NULL) {
+                Py_DECREF(item);
+                Py_DECREF(iter);
+                return NULL;
+            }
             temp = PyNumber_Add(result, item);
             Py_DECREF(result);
             Py_DECREF(item);