From c77c2a2b1e3aaf00fabf91d154d9c068dd17a66e Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Thu, 7 Sep 2017 12:04:32 -0700 Subject: [PATCH] Fix compiler complaints about arithmetic overflow in hashing --- pool.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pool.cpp b/pool.cpp index 5ac4a66e..f41c211c 100644 --- a/pool.cpp +++ b/pool.cpp @@ -14,12 +14,12 @@ int swizzlecmp(const char *a, const char *b) { return 0; } - unsigned int hash1 = 0, hash2 = 0; + long long hash1 = 0, hash2 = 0; for (ssize_t i = alen - 1; i >= 0; i--) { - hash1 = hash1 * 37 + a[i]; + hash1 = (hash1 * 37 + a[i]) & INT_MAX; } for (ssize_t i = blen - 1; i >= 0; i--) { - hash2 = hash2 * 37 + b[i]; + hash2 = (hash2 * 37 + b[i]) & INT_MAX; } int h1 = hash1, h2 = hash2;