summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-04-05 23:15:30 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-04-05 23:15:30 (GMT)
commit0aaaa62200d0bae0b79e578234ab74741da4dad3 (patch)
tree1b96702884e442782d680b45099e0b2462f0d122 /Objects
parentcb04acf425ab8cd0921707a73eab10e8c0137f15 (diff)
downloadcpython-0aaaa62200d0bae0b79e578234ab74741da4dad3.zip
cpython-0aaaa62200d0bae0b79e578234ab74741da4dad3.tar.gz
cpython-0aaaa62200d0bae0b79e578234ab74741da4dad3.tar.bz2
Issue #17469: Fix _Py_GetAllocatedBlocks() and sys.getallocatedblocks() when running on valgrind.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/obmalloc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index 5943f5a..3028f22 100644
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -778,6 +778,8 @@ PyObject_Malloc(size_t nbytes)
poolp next;
uint size;
+ _Py_AllocatedBlocks++;
+
#ifdef WITH_VALGRIND
if (UNLIKELY(running_on_valgrind == -1))
running_on_valgrind = RUNNING_ON_VALGRIND;
@@ -791,10 +793,10 @@ PyObject_Malloc(size_t nbytes)
* things without checking for overflows or negatives.
* As size_t is unsigned, checking for nbytes < 0 is not required.
*/
- if (nbytes > PY_SSIZE_T_MAX)
+ if (nbytes > PY_SSIZE_T_MAX) {
+ _Py_AllocatedBlocks--;
return NULL;
-
- _Py_AllocatedBlocks++;
+ }
/*
* This implicitly redirects malloc(0).