[Python-checkins] cpython (2.7): Issue #13018: Fix reference leaks in error paths in dictobject.c.
petri.lehtinen
python-checkins at python.org
Mon Oct 24 20:33:28 CEST 2011
http://hg.python.org/cpython/rev/5d7164febff1
changeset: 73102:5d7164febff1
branch: 2.7
parent: 73073:5c4781a237ef
user: Petri Lehtinen <petri at digip.org>
date: Mon Oct 24 20:59:29 2011 +0300
summary:
Issue #13018: Fix reference leaks in error paths in dictobject.c.
Patch by Suman Saha.
files:
Misc/NEWS | 3 +++
Objects/dictobject.c | 16 ++++++++++++----
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -9,6 +9,9 @@
Core and Builtins
-----------------
+- Issue #13018: Fix reference leaks in error paths in dictobject.c.
+ Patch by Suman Saha.
+
- Issue #12604: VTRACE macro expanded to no-op in _sre.c to avoid compiler
warnings. Patch by Josh Triplett and Petri Lehtinen.
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1335,14 +1335,18 @@
PyObject *key;
long hash;
- if (dictresize(mp, Py_SIZE(seq)))
+ if (dictresize(mp, Py_SIZE(seq))) {
+ Py_DECREF(d);
return NULL;
+ }
while (_PyDict_Next(seq, &pos, &key, &oldvalue, &hash)) {
Py_INCREF(key);
Py_INCREF(value);
- if (insertdict(mp, key, hash, value))
+ if (insertdict(mp, key, hash, value)) {
+ Py_DECREF(d);
return NULL;
+ }
}
return d;
}
@@ -1353,14 +1357,18 @@
PyObject *key;
long hash;
- if (dictresize(mp, PySet_GET_SIZE(seq)))
+ if (dictresize(mp, PySet_GET_SIZE(seq))) {
+ Py_DECREF(d);
return NULL;
+ }
while (_PySet_NextEntry(seq, &pos, &key, &hash)) {
Py_INCREF(key);
Py_INCREF(value);
- if (insertdict(mp, key, hash, value))
+ if (insertdict(mp, key, hash, value)) {
+ Py_DECREF(d);
return NULL;
+ }
}
return d;
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list