Skip to content

Commit 224c7a6

Browse files
committed
decref even if fail
1 parent 283fd58 commit 224c7a6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Python/flowgraph.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,11 +1500,11 @@ 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);
15101510
Py_DECREF(o);
@@ -1522,6 +1522,10 @@ optimize_if_const_subscr(basicblock *bb, int n, PyObject *consts, PyObject *cons
15221522
INSTR_SET_OP0(arg, NOP);
15231523
INSTR_SET_OP0(idx, NOP);
15241524
return SUCCESS;
1525+
error:
1526+
Py_XDECREF(o);
1527+
Py_XDECREF(key);
1528+
return ERROR;
15251529
}
15261530

15271531
#define VISITED (-1)

0 commit comments

Comments
 (0)