Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d3c54f3

Browse filesBrowse files
authored
gh-126835: Fix reference leak in Python/flowgrapc.::optimize_if_const_subscr (#129634)
1 parent 0664c1a commit d3c54f3
Copy full SHA for d3c54f3

File tree

1 file changed

+8
-2
lines changed
Filter options

1 file changed

+8
-2
lines changed

‎Python/flowgraph.c

Copy file name to clipboardExpand all lines: Python/flowgraph.c
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,13 +1500,15 @@ optimize_if_const_subscr(basicblock *bb, int n, PyObject *consts, PyObject *cons
15001500
if (!find_load_const_pair(bb, n-1, &arg, &idx)) {
15011501
return SUCCESS;
15021502
}
1503-
PyObject *o, *key;
1503+
PyObject *o = NULL, *key = NULL;
15041504
if ((o = get_const_value(arg->i_opcode, arg->i_oparg, consts)) == NULL
15051505
|| (key = get_const_value(idx->i_opcode, idx->i_oparg, consts)) == NULL)
15061506
{
1507-
return ERROR;
1507+
goto error;
15081508
}
15091509
PyObject *newconst = PyObject_GetItem(o, key);
1510+
Py_DECREF(o);
1511+
Py_DECREF(key);
15101512
if (newconst == NULL) {
15111513
if (PyErr_ExceptionMatches(PyExc_KeyboardInterrupt)) {
15121514
return ERROR;
@@ -1520,6 +1522,10 @@ optimize_if_const_subscr(basicblock *bb, int n, PyObject *consts, PyObject *cons
15201522
INSTR_SET_OP0(arg, NOP);
15211523
INSTR_SET_OP0(idx, NOP);
15221524
return SUCCESS;
1525+
error:
1526+
Py_XDECREF(o);
1527+
Py_XDECREF(key);
1528+
return ERROR;
15231529
}
15241530

15251531
#define VISITED (-1)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.