diff options
| author | Benjamin Peterson <benjamin@python.org> | 2011-10-25 04:04:37 (GMT) |
|---|---|---|
| committer | Benjamin Peterson <benjamin@python.org> | 2011-10-25 04:04:37 (GMT) |
| commit | 9a1b956deaddb06341d6cbfa16af9d4eee196e99 (patch) | |
| tree | dce21295fb88932b9cdfdf5e082c07b8fd4ae1ca /Objects | |
| parent | 1fafc1a11f7d4799f252a40e608b0fd4d4fedb68 (diff) | |
| parent | 64c1c0720170dbd78dbac333d4c268439ac856bc (diff) | |
| download | cpython-9a1b956deaddb06341d6cbfa16af9d4eee196e99.zip cpython-9a1b956deaddb06341d6cbfa16af9d4eee196e99.tar.gz cpython-9a1b956deaddb06341d6cbfa16af9d4eee196e99.tar.bz2 | |
merge heads
Diffstat (limited to 'Objects')
| -rw-r--r-- | Objects/dictobject.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 3fa5cc4..79894e5 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; } |
