diff options
author | Raymond Hettinger <python@rcn.com> | 2015-07-04 18:28:35 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-07-04 18:28:35 (GMT) |
commit | e186c7674cbc8d2796a7971b53daa98e60d7f601 (patch) | |
tree | 097863fb56a5b98c88325c853ed2075d53b0edbd | |
parent | c2480dc0c4cf13719c5aa514db9f579990a1603f (diff) | |
download | cpython-e186c7674cbc8d2796a7971b53daa98e60d7f601.zip cpython-e186c7674cbc8d2796a7971b53daa98e60d7f601.tar.gz cpython-e186c7674cbc8d2796a7971b53daa98e60d7f601.tar.bz2 |
Make sure the dummy percentage calculation won't overflow.
-rw-r--r-- | Objects/setobject.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c index 8e56f72..cc87f28 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -1506,8 +1506,8 @@ set_difference_update_internal(PySetObject *so, PyObject *other) if (PyErr_Occurred()) return -1; } - /* If more than 1/5 are dummies, then resize them away. */ - if ((so->fill - so->used) * 5 < so->mask) + /* If more than 1/4th are dummies, then resize them away. */ + if ((size_t)(so->fill - so->used) <= (size_t)so->mask / 4) return 0; return set_table_resize(so, so->used); } |