mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
Issue #21639: Fix a division by zero in tracemalloc on calloc(0, 0). The
regression was introduced recently with the introduction of the new "calloc" functions (PyMem_RawCalloc, PyMem_Calloc, PyObject_Calloc). Add also a unit test to check for the non-regression.
This commit is contained in:
commit
aa0e7afa43
2 changed files with 7 additions and 1 deletions
|
@ -478,7 +478,7 @@ tracemalloc_alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize)
|
|||
PyMemAllocator *alloc = (PyMemAllocator *)ctx;
|
||||
void *ptr;
|
||||
|
||||
assert(nelem <= PY_SIZE_MAX / elsize);
|
||||
assert(elsize == 0 || nelem <= PY_SIZE_MAX / elsize);
|
||||
|
||||
if (use_calloc)
|
||||
ptr = alloc->calloc(alloc->ctx, nelem, elsize);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue