summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2011-09-24 17:18:40 (GMT)
committerMark Dickinson <mdickinson@enthought.com>2011-09-24 17:18:40 (GMT)
commit57e683e53eed1455176b17304b3ac007ae7eb181 (patch)
tree983e172ad16aaaf227f4d56d34cafc416fea68eb /Objects/dictobject.c
parent0390151100e3035be8a9cca8b180a63fa19d1368 (diff)
downloadcpython-57e683e53eed1455176b17304b3ac007ae7eb181.zip
cpython-57e683e53eed1455176b17304b3ac007ae7eb181.tar.gz
cpython-57e683e53eed1455176b17304b3ac007ae7eb181.tar.bz2
Issue #1621: Fix undefined behaviour in bytes.__hash__, str.__hash__, tuple.__hash__, frozenset.__hash__ and set indexing operations.
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r--Objects/dictobject.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index cdc27ab..e76e508 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -418,7 +418,7 @@ lookdict_unicode(PyDictObject *mp, PyObject *key, register Py_hash_t hash)
mp->ma_lookup = lookdict;
return lookdict(mp, key, hash);
}
- i = hash & mask;
+ i = (size_t)hash & mask;
ep = &ep0[i];
if (ep->me_key == NULL || ep->me_key == key)
return ep;
@@ -572,7 +572,7 @@ insertdict_clean(register PyDictObject *mp, PyObject *key, Py_hash_t hash,
register PyDictEntry *ep;
MAINTAIN_TRACKING(mp, key, value);
- i = hash & mask;
+ i = (size_t)hash & mask;
ep = &ep0[i];
for (perturb = hash; ep->me_key != NULL; perturb >>= PERTURB_SHIFT) {
i = (i << 2) + i + perturb + 1;