[Python-checkins] cpython (merge 3.2 -> default): Issue #13020: Fix a reference leak when allocating a structsequence object

antoine.pitrou python-checkins at python.org
Wed Feb 15 03:00:54 CET 2012


http://hg.python.org/cpython/rev/5e0085d67f65
changeset: 74941:5e0085d67f65
parent: 74937:7cfce717ceee
parent: 74940:7f267a650a1d
user: Antoine Pitrou <solipsis at pitrou.net>
date: Wed Feb 15 02:54:33 2012 +0100
summary:
 Issue #13020: Fix a reference leak when allocating a structsequence object fails.
Patch by Suman Saha.
files:
 Misc/NEWS | 3 +++
 Objects/structseq.c | 25 +++++++++++++------------
 2 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- 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 #13777: Add PF_SYSTEM sockets on OS X.
 Patch by Michael Goderbauer.
 
diff --git a/Objects/structseq.c b/Objects/structseq.c
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -103,32 +103,33 @@
 if (min_len != max_len) {
 if (len < min_len) {
 PyErr_Format(PyExc_TypeError,
- "%.500s() takes an at least %zd-sequence (%zd-sequence given)",
- type->tp_name, min_len, len);
- Py_DECREF(arg);
- return NULL;
+ "%.500s() takes an at least %zd-sequence (%zd-sequence given)",
+ type->tp_name, min_len, len);
+ Py_DECREF(arg);
+ return NULL;
 }
 
 if (len > max_len) {
 PyErr_Format(PyExc_TypeError,
- "%.500s() takes an at most %zd-sequence (%zd-sequence given)",
- type->tp_name, max_len, len);
- Py_DECREF(arg);
- return NULL;
+ "%.500s() takes an at most %zd-sequence (%zd-sequence given)",
+ type->tp_name, max_len, len);
+ Py_DECREF(arg);
+ return NULL;
 }
 }
 else {
 if (len != min_len) {
 PyErr_Format(PyExc_TypeError,
- "%.500s() takes a %zd-sequence (%zd-sequence given)",
- type->tp_name, min_len, len);
- Py_DECREF(arg);
- return NULL;
+ "%.500s() takes a %zd-sequence (%zd-sequence given)",
+ type->tp_name, min_len, len);
+ Py_DECREF(arg);
+ return NULL;
 }
 }
 
 res = (PyStructSequence*) PyStructSequence_New(type);
 if (res == NULL) {
+ Py_DECREF(arg);
 return NULL;
 }
 for (i = 0; i < len; ++i) {
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /