]> granicus.if.org Git - python/commitdiff
Make sure the dummy percentage calculation won't overflow.
authorRaymond Hettinger <python@rcn.com>
Sat, 4 Jul 2015 18:28:35 +0000 (11:28 -0700)
committerRaymond Hettinger <python@rcn.com>
Sat, 4 Jul 2015 18:28:35 +0000 (11:28 -0700)
Objects/setobject.c

index 8e56f7258bc813aa9680577d8d7f694221870e90..cc87f284f60d9111fcf1bb986fc2b6ad6b9a804f 100644 (file)
@@ -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);
 }