summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2011-10-24 18:17:52 (GMT)
committerPetri Lehtinen <petri@digip.org>2011-10-24 18:17:52 (GMT)
commit24bd5adcffb490a3f7523142cf663a03dfd5f5c5 (patch)
treef6b89fd18bd520850ca881d837642e9ecd9c1d6a
parent36645681c8ad9a30d142f1dabb44d1d6c3ed5fab (diff)
parenta94200e6ce17d794c121cbeff7d9b61b206a2429 (diff)
downloadcpython-24bd5adcffb490a3f7523142cf663a03dfd5f5c5.zip
cpython-24bd5adcffb490a3f7523142cf663a03dfd5f5c5.tar.gz
cpython-24bd5adcffb490a3f7523142cf663a03dfd5f5c5.tar.bz2
Merge 3.2
-rw-r--r--Misc/NEWS3
-rw-r--r--Objects/dictobject.c16
2 files changed, 15 insertions, 4 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index e6ee120..7f68030 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1?
Core and Builtins
-----------------
+- Issue #13018: Fix reference leaks in error paths in dictobject.c.
+ Patch by Suman Saha.
+
- Issue #13201: Define '==' and '!=' to compare range objects based on
the sequence of values they define (instead of comparing based on
object identity).
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 865feff..82735e6 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1314,14 +1314,18 @@ dict_fromkeys(PyObject *cls, PyObject *args)
PyObject *key;
Py_hash_t 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;
}
@@ -1332,14 +1336,18 @@ dict_fromkeys(PyObject *cls, PyObject *args)
PyObject *key;
Py_hash_t 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;
}