Skip to content

Commit 4b0c875

Browse files
authored
[3.12] gh-109181: Fix refleak in tb_get_lineno() (#111948)
PyFrame_GetCode() returns a strong reference.
1 parent 881c9eb commit 4b0c875

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Python/traceback.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ static int
111111
tb_get_lineno(PyTracebackObject* tb) {
112112
PyFrameObject* frame = tb->tb_frame;
113113
assert(frame != NULL);
114-
return PyCode_Addr2Line(PyFrame_GetCode(frame), tb->tb_lasti);
114+
PyCodeObject *code = PyFrame_GetCode(frame);
115+
int lineno = PyCode_Addr2Line(code, tb->tb_lasti);
116+
Py_DECREF(code);
117+
return lineno;
115118
}
116119

117120
static PyObject *

0 commit comments

Comments
 (0)