mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
Issue #1621: Fix undefined behaviour from signed overflow in datetime module hashes, array and list iterations, and get_integer (stringlib/string_format.h)
This commit is contained in:
parent
50203a69b3
commit
c7d93b7614
4 changed files with 14 additions and 16 deletions
|
@ -2746,13 +2746,13 @@ static Py_hash_t
|
|||
generic_hash(unsigned char *data, int len)
|
||||
{
|
||||
register unsigned char *p;
|
||||
register Py_hash_t x;
|
||||
register Py_uhash_t x;
|
||||
|
||||
p = (unsigned char *) data;
|
||||
x = *p << 7;
|
||||
x = (Py_uhash_t)*p << 7;
|
||||
while (--len >= 0)
|
||||
x = (1000003*x) ^ *p++;
|
||||
x ^= len;
|
||||
x = (1000003U*x) ^ (Py_uhash_t)*p++;
|
||||
x ^= (Py_uhash_t)len;
|
||||
if (x == -1)
|
||||
x = -2;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue