summaryrefslogtreecommitdiff
path: root/Lib/test/test_tracemalloc.py
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
commitaa0e7afa438d7586353a3338fd350449714e117a (patch)
treece0e03763435ae51fd10a8017e3cd522fff198d1 /Lib/test/test_tracemalloc.py
parent38d65dff7c7f929fbefd83a887ff8997d96e2505 (diff)
parent8dd49fe09fc4ac3b527914a0703c0dc0429aa125 (diff)
downloadcpython-git-aa0e7afa438d7586353a3338fd350449714e117a.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 'Lib/test/test_tracemalloc.py')
-rw-r--r--Lib/test/test_tracemalloc.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_tracemalloc.py b/Lib/test/test_tracemalloc.py
index c953885fc5..33b0dc2b0e 100644
--- a/Lib/test/test_tracemalloc.py
+++ b/Lib/test/test_tracemalloc.py
@@ -807,6 +807,12 @@ class TestCommandLine(unittest.TestCase):
b'number of frames',
stderr)
+ def test_pymem_alloc0(self):
+ # Issue #21639: Check that PyMem_Malloc(0) with tracemalloc enabled
+ # does not crash.
+ code = 'import _testcapi; _testcapi.test_pymem_alloc0(); 1'
+ assert_python_ok('-X', 'tracemalloc', '-c', code)
+
def test_main():
support.run_unittest(