Skip to content

Commit efb497b

Browse files
committed
Fix refleak in object.c
1 parent e4fa631 commit efb497b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Objects/object.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,7 @@ _PyObject_SetAttributeErrorContext(PyObject* v, PyObject* name)
12951295
// Augment the exception with the name and object
12961296
if (PyObject_SetAttr(exc, &_Py_ID(name), name) ||
12971297
PyObject_SetAttr(exc, &_Py_ID(obj), v)) {
1298+
Py_DECREF(exc);
12981299
return 1;
12991300
}
13001301
restore:
@@ -3077,9 +3078,9 @@ Py_ReprEnter(PyObject *obj)
30773078
list = PyList_New(0);
30783079
if (list == NULL)
30793080
return -1;
3080-
if (PyDict_SetItem(dict, &_Py_ID(Py_Repr), list) < 0)
3081+
if (_PyDict_SetItem_Take(dict, &_Py_ID(Py_Repr), list) < 0) {
30813082
return -1;
3082-
Py_DECREF(list);
3083+
}
30833084
}
30843085
i = PyList_GET_SIZE(list);
30853086
while (--i >= 0) {

0 commit comments

Comments
 (0)