[Python-checkins] cpython (3.3): Issue #18560: Fix potential NULL pointer dereference in sum()

christian.heimes python-checkins at python.org
Fri Jul 26 22:50:11 CEST 2013


http://hg.python.org/cpython/rev/de7e4fd634fb
changeset:   84846:de7e4fd634fb
branch:      3.3
parent:      84844:dbdd07657e23
user:        Christian Heimes <christian at cheimes.de>
date:        Fri Jul 26 22:49:26 2013 +0200
summary:
  Issue #18560: Fix potential NULL pointer dereference in sum()

files:
  Misc/NEWS            |  2 ++
  Python/bltinmodule.c |  5 +++++
  2 files changed, 7 insertions(+), 0 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@
 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.
 
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -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);

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list