From: Raymond Hettinger Date: Sat, 4 Jul 2015 18:28:35 +0000 (-0700) Subject: Make sure the dummy percentage calculation won't overflow. X-Git-Tag: v3.6.0a1~2004^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e186c7674cbc8d2796a7971b53daa98e60d7f601;p=python Make sure the dummy percentage calculation won't overflow. --- diff --git a/Objects/setobject.c b/Objects/setobject.c index 8e56f7258b..cc87f284f6 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); }