[3.12] gh-109181: Fix refleak in tb_get_lineno() (#111948)

PyFrame_GetCode() returns a strong reference.
This commit is contained in:
Victor Stinner 2023-11-10 14:07:45 +01:00 committed by GitHub
parent 881c9eb962
commit 4b0c875d91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 *