summaryrefslogtreecommitdiffstats
path: root/Modules/_lsprof.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-04-28 23:28:13 (GMT)
committerGitHub <noreply@github.com>2020-04-28 23:28:13 (GMT)
commit8852ad4208e34825f74e24945edb5bcf055d94fe (patch)
tree157f239ba46634301e136f4662b1646f7258357e /Modules/_lsprof.c
parent5e8c691594d68925213d36296ce7c4b3e90bcb1d (diff)
downloadcpython-8852ad4208e34825f74e24945edb5bcf055d94fe.zip
cpython-8852ad4208e34825f74e24945edb5bcf055d94fe.tar.gz
cpython-8852ad4208e34825f74e24945edb5bcf055d94fe.tar.bz2
bpo-40429: PyFrame_GetCode() now returns a strong reference (GH-19773)
Diffstat (limited to 'Modules/_lsprof.c')
-rw-r--r--Modules/_lsprof.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c
index 39cf6e1..5e53d83 100644
--- a/Modules/_lsprof.c
+++ b/Modules/_lsprof.c
@@ -390,14 +390,19 @@ profiler_callback(PyObject *self, PyFrameObject *frame, int what,
{
PyCodeObject *code = PyFrame_GetCode(frame);
ptrace_enter_call(self, (void *)code, (PyObject *)code);
+ Py_DECREF(code);
break;
}
/* the 'frame' of a called function is about to finish
(either normally or with an exception) */
case PyTrace_RETURN:
- ptrace_leave_call(self, (void *)PyFrame_GetCode(frame));
+ {
+ PyCodeObject *code = PyFrame_GetCode(frame);
+ ptrace_leave_call(self, (void *)code);
+ Py_DECREF(code);
break;
+ }
/* case PyTrace_EXCEPTION:
If the exception results in the function exiting, a