From 77ccca8a4264f354b6f3b4e859fd3b82bba2ce84 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 14 Oct 2018 12:31:52 -0700 Subject: [PATCH] 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. --- src/libpspp/hash-functions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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]; -- 2.30.2