[Python-checkins] cpython: Issue #21233: Oops, Fix _PyObject_Alloc(): initialize nbytes before going to

victor.stinner python-checkins at python.org
Fri May 2 23:26:18 CEST 2014


http://hg.python.org/cpython/rev/62438d1b11c7
changeset:   90541:62438d1b11c7
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Fri May 02 23:26:03 2014 +0200
summary:
  Issue #21233: Oops, Fix _PyObject_Alloc(): initialize nbytes before going to
redirect.

files:
  Objects/obmalloc.c |  6 +++---
  1 files changed, 3 insertions(+), 3 deletions(-)


diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -1183,12 +1183,12 @@
         goto redirect;
 #endif
 
+    assert(nelem <= PY_SSIZE_T_MAX / elsize);
+    nbytes = nelem * elsize;
+
     if (nelem == 0 || elsize == 0)
         goto redirect;
 
-    assert(nelem <= PY_SSIZE_T_MAX / elsize);
-    nbytes = nelem * elsize;
-
     if ((nbytes - 1) < SMALL_REQUEST_THRESHOLD) {
         LOCK();
         /*

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


More information about the Python-checkins mailing list