Skip to content

Commit 2e19e8e

Browse files
committed
Issue #13015: Fix a possible reference leak in defaultdict.__repr__.
Patch by Suman Saha.
1 parent 8541587 commit 2e19e8e

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ Core and Builtins
9090
Library
9191
-------
9292

93+
- Issue #13015: Fix a possible reference leak in defaultdict.__repr__.
94+
Patch by Suman Saha.
95+
9396
- Issue #13979: A bug in ctypes.util.find_library that caused
9497
the wrong library name to be returned has been fixed.
9598

Modules/_collectionsmodule.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1475,8 +1475,10 @@ defdict_repr(defdictobject *dd)
14751475
{
14761476
int status = Py_ReprEnter(dd->default_factory);
14771477
if (status != 0) {
1478-
if (status < 0)
1478+
if (status < 0) {
1479+
Py_DECREF(baserepr);
14791480
return NULL;
1481+
}
14801482
defrepr = PyString_FromString("...");
14811483
}
14821484
else

0 commit comments

Comments
 (0)