diff options
author | Guido van Rossum <guido@python.org> | 2004-03-20 19:11:58 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2004-03-20 19:11:58 (GMT) |
commit | 09240f65f8becdb72bb72bd44817e11c7192b24f (patch) | |
tree | fa0ccd8d143a5b7f5e3e14970fc54663a45c266e | |
parent | fe703e0650cdbbf35c74c227c8be198dff153145 (diff) | |
download | cpython-09240f65f8becdb72bb72bd44817e11c7192b24f.zip cpython-09240f65f8becdb72bb72bd44817e11c7192b24f.tar.gz cpython-09240f65f8becdb72bb72bd44817e11c7192b24f.tar.bz2 |
GCC was complaining that 'value' in dictiter_iternextvalue() wasn't
necessarily always set before used. Between Tim, Armin & me we
couldn't prove GCC wrong, so we decided to fix the algorithm. This
version is Armin's.
-rw-r--r-- | Objects/dictobject.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 3e36961..0f2a271 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -2148,15 +2148,16 @@ static PyObject *dictiter_iternextvalue(dictiterobject *di) } i = di->di_pos; - if (i < 0) + mask = d->ma_mask; + if (i < 0 || i > mask) goto fail; ep = d->ma_table; - mask = d->ma_mask; - while (i <= mask && (value=ep[i].me_value) == NULL) + while ((value=ep[i].me_value) == NULL) { i++; + if (i > mask) + goto fail; + } di->di_pos = i+1; - if (i > mask) - goto fail; di->len--; Py_INCREF(value); return value; |