]> granicus.if.org Git - python/commitdiff
Issue #18560: Fix potential NULL pointer dereference in sum()
authorChristian Heimes <christian@cheimes.de>
Fri, 26 Jul 2013 20:49:26 +0000 (22:49 +0200)
committerChristian Heimes <christian@cheimes.de>
Fri, 26 Jul 2013 20:49:26 +0000 (22:49 +0200)
Misc/NEWS
Python/bltinmodule.c

index 24b0c53f6cd0bcd058c6c83374e4c7dd03497ea3..505fab58209fb58b526f4d1da7c9291fc25794ae 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 3.3.3 release candidate 1?
 Core and Builtins
 -----------------
 
+- Issue #18560: Fix potential NULL pointer dereference in sum().
+
 - Issue #15905: Fix theoretical buffer overflow in handling of sys.argv[0],
   prefix and exec_prefix if the operation system does not obey MAXPATHLEN.
 
index 4fe8dace5938f105471cefe2df42ac173ee95b48..b07ee8ec328abd4432be8ceb022b422b67b00066 100644 (file)
@@ -2009,6 +2009,11 @@ builtin_sum(PyObject *self, PyObject *args)
             }
             /* 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);