summaryrefslogtreecommitdiff
path: root/Modules/_tracemalloc.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-06-02 21:40:22 +0200
committerVictor Stinner <victor.stinner@gmail.com>2014-06-02 21:40:22 +0200
commit0f571c51806701a8dd01094987f124b69731dc51 (patch)
tree7c4d4582020f9d7943f451fe79a4aed25bd7df9f /Modules/_tracemalloc.c
parent0a6245e4ce5ca45af848220de4ed8e5da28e65e7 (diff)
parent84c7af6f09051e1b14182da75b0a80ae454af5d7 (diff)
downloadcpython-0f571c51806701a8dd01094987f124b69731dc51.tar.gz
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.
Diffstat (limited to 'Modules/_tracemalloc.c')
-rw-r--r--Modules/_tracemalloc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c
index 429b209c02..1e454144de 100644
--- a/Modules/_tracemalloc.c
+++ b/Modules/_tracemalloc.c
@@ -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);