]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #21233: Fix _PyObject_Alloc() when compiled with WITH_VALGRIND defined
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 6 May 2014 09:32:29 +0000 (11:32 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 6 May 2014 09:32:29 +0000 (11:32 +0200)
Objects/obmalloc.c

index e16a1db808d51c034441e10244e0245e44d5b1cf..af2bab07b294b23890046481d1d5a59343f13e8d 100644 (file)
@@ -1176,6 +1176,9 @@ _PyObject_Alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize)
 
     _Py_AllocatedBlocks++;
 
+    assert(nelem <= PY_SSIZE_T_MAX / elsize);
+    nbytes = nelem * elsize;
+
 #ifdef WITH_VALGRIND
     if (UNLIKELY(running_on_valgrind == -1))
         running_on_valgrind = RUNNING_ON_VALGRIND;
@@ -1183,9 +1186,6 @@ _PyObject_Alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize)
         goto redirect;
 #endif
 
-    assert(nelem <= PY_SSIZE_T_MAX / elsize);
-    nbytes = nelem * elsize;
-
     if (nelem == 0 || elsize == 0)
         goto redirect;