summaryrefslogtreecommitdiffstats
path: root/Modules/_tracemalloc.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-06-02 19:40:22 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-06-02 19:40:22 (GMT)
commitaa0e7afa438d7586353a3338fd350449714e117a (patch)
treece0e03763435ae51fd10a8017e3cd522fff198d1 /Modules/_tracemalloc.c
parent38d65dff7c7f929fbefd83a887ff8997d96e2505 (diff)
parent8dd49fe09fc4ac3b527914a0703c0dc0429aa125 (diff)
downloadcpython-aa0e7afa438d7586353a3338fd350449714e117a.zip
cpython-aa0e7afa438d7586353a3338fd350449714e117a.tar.gz
cpython-aa0e7afa438d7586353a3338fd350449714e117a.tar.bz2
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 429b209..1e45414 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);