[PATCH 5/6] hashcode-mem: don’t infloop i f UINT_MAX < size

Paul Eggert <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs
Message-ID <[email protected]>
* lib/hashcode-mem.c (hash_pjw_bare): Use size_t for loop index.
---
 ChangeLog          | 3 +++
 lib/hashcode-mem.c | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 11744aeb9d..03575cf89b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2026-06-26  Paul Eggert  <[email protected]>
 
+	hashcode-mem: don’t infloop if UINT_MAX < size
+	* lib/hashcode-mem.c (hash_pjw_bare): Use size_t for loop index.
+
 	gen-uni-tables: prefer size_t for size loops
 	* lib/gen-uni-tables.c (output_predicate, output_category)
 	(output_combclass, output_bidi_category, output_decimal_digit)
diff --git a/lib/hashcode-mem.c b/lib/hashcode-mem.c
index a4963afb68..30ee835107 100644
--- a/lib/hashcode-mem.c
+++ b/lib/hashcode-mem.c
@@ -34,7 +34,7 @@ hash_pjw_bare (const void *x, size_t n)
   const unsigned char *s = x;
   size_t h = 0;
 
-  for (unsigned int i = 0; i < n; i++)
+  for (size_t i = 0; i < n; i++)
     h = s[i] + stdc_rotate_left (h, 9);
 
   return h;
-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.