summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-11-10 13:07:45 (GMT)
committerGitHub <noreply@github.com>2023-11-10 13:07:45 (GMT)
commit4b0c875d91727440251a8427a80d8515e39d18cd (patch)
tree5d5d48b22460823b2967b4702fad82c0693661db /Python
parent881c9eb962608da8deb4d48fe1642f714ce00b91 (diff)
downloadcpython-4b0c875d91727440251a8427a80d8515e39d18cd.zip
cpython-4b0c875d91727440251a8427a80d8515e39d18cd.tar.gz
cpython-4b0c875d91727440251a8427a80d8515e39d18cd.tar.bz2
[3.12] gh-109181: Fix refleak in tb_get_lineno() (#111948)
PyFrame_GetCode() returns a strong reference.
Diffstat (limited to 'Python')
-rw-r--r--Python/traceback.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Python/traceback.c b/Python/traceback.c
index b627b06..fdaf19d 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -111,7 +111,10 @@ static int
tb_get_lineno(PyTracebackObject* tb) {
PyFrameObject* frame = tb->tb_frame;
assert(frame != NULL);
- return PyCode_Addr2Line(PyFrame_GetCode(frame), tb->tb_lasti);
+ PyCodeObject *code = PyFrame_GetCode(frame);
+ int lineno = PyCode_Addr2Line(code, tb->tb_lasti);
+ Py_DECREF(code);
+ return lineno;
}
static PyObject *