From: Ben Pfaff Date: Sun, 14 Oct 2018 19:31:52 +0000 (-0700) Subject: hash-functions: Avoid signed integer overflow. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77ccca8a4264f354b6f3b4e859fd3b82bba2ce84;p=pspp hash-functions: Avoid signed integer overflow. cppcheck reported that 0xdeadbeef + 8 yielded signed integer overflow. This is probably harmless, as long as the compiler doesn't do something really strange, but it's even better if we just ensure that this arithmetic is done as unsigned. Reported by John Darrington. --- diff --git a/src/libpspp/hash-functions.c b/src/libpspp/hash-functions.c index 7a8d8162ec..4de7f77791 100644 --- a/src/libpspp/hash-functions.c +++ b/src/libpspp/hash-functions.c @@ -125,7 +125,7 @@ hash_double (double d, unsigned int basis) uint32_t tmp[2]; uint32_t a, b, c; - a = b = c = 0xdeadbeef + 8 + basis; + a = b = c = 0xdeadbeefU + 8 + basis; memcpy (tmp, &d, 8); a += tmp[0];