File glibc-2.10-hsearch.diff of Package glibc
commit c2d5bd5b00cfbb0ef192821f2d724fb6448d59e3
Author: Ulrich Drepper <drepper@redhat.com>
Date: Fri Apr 24 18:20:10 2009 +0000
[BZ #10100]
2009-04-24 Ulrich Drepper <drepper@redhat.com>
[BZ #10100]
* misc/hsearch_r.c (hsearch_r): Add back ensurance that hval is
not zero.
diff --git a/misc/hsearch_r.c b/misc/hsearch_r.c
index 6e32afc..73b9565 100644
--- misc/hsearch_r.c
+++ misc/hsearch_r.c
@@ -157,6 +157,8 @@ hsearch_r (item, action, retval, htab)
hval <<= 4;
hval += item.key[count];
}
+ if (hval == 0)
+ ++hval;
/* First hash function: simply take the modul but prevent zero. */
idx = hval % htab->size + 1;
commit 8073a49484461fbf71cacb154cc2aa2cdac0cca2
Author: Ulrich Drepper <drepper@redhat.com>
Date: Fri Jan 23 20:34:21 2009 +0000
(hcreate_r): We need at least three elements in the hash table.
diff --git a/misc/hsearch_r.c b/misc/hsearch_r.c
index c855a41..6e32afc 100644
--- misc/hsearch_r.c
+++ misc/hsearch_r.c
@@ -79,6 +79,10 @@ hcreate_r (nel, htab)
if (htab->table != NULL)
return 0;
+ /* We need a size of at least 3. Otherwise the hash functions we
+ use will not work. */
+ if (nel < 3)
+ nel = 3;
/* Change nel to the first prime number not smaller as nel. */
nel |= 1; /* make odd */
while (!isprime (nel))