Issue #13020: Fix a reference leak when allocating a structsequence object fails.
Patch by Suman Saha.
diff --git a/Misc/NEWS b/Misc/NEWS
index 0ef337c..4d3d665 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
Core and Builtins
-----------------
+- Issue #13020: Fix a reference leak when allocating a structsequence object
+ fails. Patch by Suman Saha.
+
- Issue #13908: Ready types returned from PyType_FromSpec.
- Issue #11235: Fix OverflowError when trying to import a source file whose
diff --git a/Objects/structseq.c b/Objects/structseq.c
index ef17f49..ac4f980 100644
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -129,6 +129,7 @@
res = (PyStructSequence*) PyStructSequence_New(type);
if (res == NULL) {
+ Py_DECREF(arg);
return NULL;
}
for (i = 0; i < len; ++i) {