diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-06-02 21:40:22 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-06-02 21:40:22 +0200 |
commit | 0f571c51806701a8dd01094987f124b69731dc51 (patch) | |
tree | 7c4d4582020f9d7943f451fe79a4aed25bd7df9f /Modules/_tracemalloc.c | |
parent | 0a6245e4ce5ca45af848220de4ed8e5da28e65e7 (diff) | |
parent | 84c7af6f09051e1b14182da75b0a80ae454af5d7 (diff) | |
download | cpython-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.c | 2 |
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); |