summaryrefslogtreecommitdiffstats
path: root/Modules/_tracemalloc.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-04-29 01:01:43 (GMT)
committerGitHub <noreply@github.com>2020-04-29 01:01:43 (GMT)
commit4386b9045e5fe1151e65c2816264b5710000eb9f (patch)
treec1bcaffac32a12c8e8f52c1e621d18665b06ac6b /Modules/_tracemalloc.c
parent37af21b667a9f41437b5b8e451497d7725016df5 (diff)
downloadcpython-4386b9045e5fe1151e65c2816264b5710000eb9f.zip
cpython-4386b9045e5fe1151e65c2816264b5710000eb9f.tar.gz
cpython-4386b9045e5fe1151e65c2816264b5710000eb9f.tar.bz2
bpo-40429: PyThreadState_GetFrame() returns a strong ref (GH-19781)
The PyThreadState_GetFrame() function now returns a strong reference to the frame.
Diffstat (limited to 'Modules/_tracemalloc.c')
-rw-r--r--Modules/_tracemalloc.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c
index 24628a9..6f28f7f 100644
--- a/Modules/_tracemalloc.c
+++ b/Modules/_tracemalloc.c
@@ -425,10 +425,7 @@ traceback_hash(traceback_t *traceback)
static void
traceback_get_frames(traceback_t *traceback)
{
- PyThreadState *tstate;
- PyFrameObject *pyframe;
-
- tstate = PyGILState_GetThisThreadState();
+ PyThreadState *tstate = PyGILState_GetThisThreadState();
if (tstate == NULL) {
#ifdef TRACE_DEBUG
tracemalloc_error("failed to get the current thread state");
@@ -436,7 +433,8 @@ traceback_get_frames(traceback_t *traceback)
return;
}
- pyframe = PyThreadState_GetFrame(tstate);
+ PyFrameObject *pyframe = PyThreadState_GetFrame(tstate);
+ Py_XDECREF(pyframe); // use a borrowed reference
for (; pyframe != NULL; pyframe = pyframe->f_back) {
if (traceback->nframe < _Py_tracemalloc_config.max_nframe) {
tracemalloc_get_frame(pyframe, &traceback->frames[traceback->nframe]);