summaryrefslogtreecommitdiffstats
path: root/Objects/odictobject.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2015-06-04 19:34:20 (GMT)
committerBenjamin Peterson <benjamin@python.org>2015-06-04 19:34:20 (GMT)
commit2ad80f53c1a9abf1d3d869a5e7902f30086f0df1 (patch)
tree8df832c614a1c55256ec06d4b605f13d105ee2ac /Objects/odictobject.c
parent4180e43c12970d6a92922bfe543ac3c24edd7d5c (diff)
downloadcpython-2ad80f53c1a9abf1d3d869a5e7902f30086f0df1.zip
cpython-2ad80f53c1a9abf1d3d869a5e7902f30086f0df1.tar.gz
cpython-2ad80f53c1a9abf1d3d869a5e7902f30086f0df1.tar.bz2
fix refleak when keys() fails
Diffstat (limited to 'Objects/odictobject.c')
-rw-r--r--Objects/odictobject.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Objects/odictobject.c b/Objects/odictobject.c
index 313b21a..13ffdf1 100644
--- a/Objects/odictobject.c
+++ b/Objects/odictobject.c
@@ -2427,12 +2427,16 @@ mutablemapping_update(PyObject *self, PyObject *args, PyObject *kwargs)
else if (PyObject_HasAttrString(other, "keys")) { /* never fails */
PyObject *keys, *iterator, *key;
keys = PyObject_CallMethod(other, "keys", NULL);
- if (keys == NULL)
+ if (keys == NULL) {
+ Py_DECREF(other);
return NULL;
+ }
iterator = PyObject_GetIter(keys);
Py_DECREF(keys);
- if (iterator == NULL)
+ if (iterator == NULL) {
+ Py_DECREF(other);
return NULL;
+ }
while (res == 0 && (key = PyIter_Next(iterator))) {
PyObject *value = PyObject_GetItem(other, key);
if (value != NULL) {