summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2013-03-04 14:48:30 (GMT)
committerBenjamin Peterson <benjamin@python.org>2013-03-04 14:48:30 (GMT)
commit42f382facd09e4ae9e2a3a082c35bd7e3ce33931 (patch)
tree812e9bf1bfacf83ce537b278f3a75dd380a7aae7
parent63f40d7af442e8d1fbb50ca0f8c5faf815f5ccbb (diff)
parentb1efa53662385ba64289d9fe6fb8ca5b431c4119 (diff)
downloadcpython-42f382facd09e4ae9e2a3a082c35bd7e3ce33931.zip
cpython-42f382facd09e4ae9e2a3a082c35bd7e3ce33931.tar.gz
cpython-42f382facd09e4ae9e2a3a082c35bd7e3ce33931.tar.bz2
merge 3.3 (#17328)
-rw-r--r--Misc/NEWS2
-rw-r--r--Objects/dictobject.c4
2 files changed, 4 insertions, 2 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 2f24d0b..80d139a 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -13,6 +13,8 @@ Core and Builtins
- Issue #17032: The "global" in the "NameError: global name 'x' is not defined"
error message has been removed. Patch by Ram Rachum.
+- Issue #17328: Fix possible refleak in dict.setdefault.
+
- Issue #17223: array module: Fix a crasher when converting an array containing
invalid characters (outside range [U+0000; U+10ffff]) to Unicode:
repr(array), str(array) and array.tounicode(). Patch written by Manuel Jacob.
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index a3c6409..9080ddf 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -2235,14 +2235,14 @@ dict_setdefault(register PyDictObject *mp, PyObject *args)
return NULL;
val = *value_addr;
if (val == NULL) {
- Py_INCREF(failobj);
- Py_INCREF(key);
if (mp->ma_keys->dk_usable <= 0) {
/* Need to resize. */
if (insertion_resize(mp) < 0)
return NULL;
ep = find_empty_slot(mp, key, hash, &value_addr);
}
+ Py_INCREF(failobj);
+ Py_INCREF(key);
MAINTAIN_TRACKING(mp, key, failobj);
ep->me_key = key;
ep->me_hash = hash;