Skip to content

Commit 3080d92

Browse files
committed
Issue python#21233: Fix _PyObject_Alloc() when compiled with WITH_VALGRIND defined
1 parent 8c9f480 commit 3080d92

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Objects/obmalloc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,16 +1176,16 @@ _PyObject_Alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize)
11761176

11771177
_Py_AllocatedBlocks++;
11781178

1179+
assert(nelem <= PY_SSIZE_T_MAX / elsize);
1180+
nbytes = nelem * elsize;
1181+
11791182
#ifdef WITH_VALGRIND
11801183
if (UNLIKELY(running_on_valgrind == -1))
11811184
running_on_valgrind = RUNNING_ON_VALGRIND;
11821185
if (UNLIKELY(running_on_valgrind))
11831186
goto redirect;
11841187
#endif
11851188

1186-
assert(nelem <= PY_SSIZE_T_MAX / elsize);
1187-
nbytes = nelem * elsize;
1188-
11891189
if (nelem == 0 || elsize == 0)
11901190
goto redirect;
11911191

0 commit comments

Comments
 (0)