shithub: mc

Download patch

ref: 3321a6568822c6278aa4e85845592596521a523f
parent: 48996257e5e74a72258db974a03ba8e40ce9287f
author: Ori Bernstein <[email protected]>
date: Sun Aug 23 19:52:12 EDT 2015

Fix hash table bug.

    This table was intially designed with no provisions for
    deletion.

--- a/parse/htab.c
+++ b/parse/htab.c
@@ -135,12 +135,14 @@
     di = 0;
     h = hash(ht, k);
     i = h & (ht->sz - 1);
-    while (ht->hashes[i] && !ht->dead[i] && ht->hashes[i] != h) {
+    while (ht->hashes[i] && ht->hashes[i] != h) {
 searchmore:
         di++;
         i = (h + di) & (ht->sz - 1);
     }
-    if (!ht->hashes[i] || ht->dead[i]) 
+    if (ht->dead[i])
+        goto searchmore;
+    if (!ht->hashes[i]) 
         return -1;
     if (!ht->cmp(ht->keys[i], k))
         goto searchmore; /* collision */