summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2013-03-04 14:47:50 (GMT)
committerBenjamin Peterson <benjamin@python.org>2013-03-04 14:47:50 (GMT)
commitb1efa53662385ba64289d9fe6fb8ca5b431c4119 (patch)
tree0b4aa7cebe47ada3cb12b4ef3d9a155fd79e2158 /Objects
parent296069301ac51d95fe5e30b4abf518940f10346d (diff)
downloadcpython-b1efa53662385ba64289d9fe6fb8ca5b431c4119.zip
cpython-b1efa53662385ba64289d9fe6fb8ca5b431c4119.tar.gz
cpython-b1efa53662385ba64289d9fe6fb8ca5b431c4119.tar.bz2
fix possible setdefault refleak (closes #17328)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/dictobject.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index f4ad3dc..8c09e46 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -2230,14 +2230,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;