Skip to content

Commit 3bd4ede

Browse files
committed
Fix refleaks
1 parent ae8f217 commit 3bd4ede

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

Modules/_testinternalcapi/set.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ set_next_entry(PyObject *self, PyObject *args)
3232
rc = _PySet_NextEntryRef(set, &pos, &item, &hash);
3333
Py_END_CRITICAL_SECTION();
3434
if (rc == 1) {
35-
return Py_BuildValue("innO", rc, pos, hash, item);
35+
PyObject *ret = Py_BuildValue("innO", rc, pos, hash, item);
36+
Py_DECREF(item);
37+
return ret;
3638
}
3739
assert(item == UNINITIALIZED_PTR);
3840
assert(hash == (Py_hash_t)UNINITIALIZED_SIZE);

Objects/dictobject.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2983,8 +2983,7 @@ dict_set_fromkeys(PyInterpreterState *interp, PyDictObject *mp,
29832983
while (_PySet_NextEntryRef(iterable, &pos, &key, &hash)) {
29842984
if (insertdict(interp, mp, key, hash, Py_NewRef(value))) {
29852985
Py_DECREF(mp);
2986-
mp = NULL;
2987-
break;
2986+
return NULL;
29882987
}
29892988
}
29902989
return mp;

Python/marshal.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ w_complex_object(PyObject *v, char flag, WFILE *p)
538538
p->version, p->allow_code);
539539
if (dump == NULL) {
540540
p->error = WFERR_UNMARSHALLABLE;
541+
Py_DECREF(value);
541542
break;
542543
}
543544
PyObject *pair = PyTuple_Pack(2, dump, value);

0 commit comments

Comments
 (0)