]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #21233: Oops, Fix _PyObject_Alloc(): initialize nbytes before going to
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 2 May 2014 21:26:03 +0000 (23:26 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Fri, 2 May 2014 21:26:03 +0000 (23:26 +0200)
redirect.

Objects/obmalloc.c

index 9fd7b31c86377698f0b81cee0cec090f92999484..e16a1db808d51c034441e10244e0245e44d5b1cf 100644 (file)
@@ -1183,12 +1183,12 @@ _PyObject_Alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize)
         goto redirect;
 #endif
 
-    if (nelem == 0 || elsize == 0)
-        goto redirect;
-
     assert(nelem <= PY_SSIZE_T_MAX / elsize);
     nbytes = nelem * elsize;
 
+    if (nelem == 0 || elsize == 0)
+        goto redirect;
+
     if ((nbytes - 1) < SMALL_REQUEST_THRESHOLD) {
         LOCK();
         /*