Skip to content

Commit

Permalink
[3.12] gh-109181: Fix refleak in tb_get_lineno() (#111948)
Browse files Browse the repository at this point in the history
PyFrame_GetCode() returns a strong reference.
  • Loading branch information
vstinner committed Nov 10, 2023
1 parent 881c9eb commit 4b0c875
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Python/traceback.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down

0 comments on commit 4b0c875

Please sign in to comment.