Skip to content

Commit 692fbb7

Browse files
committed
[mypyc] Fix refleak in str index
Found by @devdanzin
1 parent 8e3c99a commit 692fbb7

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

mypyc/lib-rt/str_ops.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,12 @@ PyObject *CPyStr_GetItem(PyObject *str, CPyTagged index) {
131131
}
132132
} else {
133133
PyObject *index_obj = CPyTagged_AsObject(index);
134-
return PyObject_GetItem(str, index_obj);
134+
if (index_obj == NULL) {
135+
return NULL;
136+
}
137+
PyObject *result = PyObject_GetItem(str, index_obj);
138+
Py_DECREF(index_obj);
139+
return result;
135140
}
136141
}
137142

0 commit comments

Comments
 (0)