* DeleteEntryFromHash(): don't skip indirection via the lookuptable, else we free...
[citadel.git] / libcitadel / lib / hash.c
index f9ceeced3d82fe94cd282c56d7d970af5f24ff81..ac6a377ff16ff188a62d2bfc9bea993b8ac63042 100644 (file)
@@ -651,8 +651,8 @@ int DeleteEntryFromHash(HashList *Hash, HashPos *At)
                return 0;
        }
 
-       FreeMe = Hash->Members[At->Position];
-       Hash->Members[At->Position] = NULL;
+       FreeMe = Hash->Members[Hash->LookupTable[At->Position]->Position];
+       Hash->Members[Hash->LookupTable[At->Position]->Position] = NULL;
 
 
        /** delete our hashing data */
@@ -667,6 +667,7 @@ int DeleteEntryFromHash(HashList *Hash, HashPos *At)
                                (Hash->nLookupTableItems - At->Position - 1) * 
                                sizeof(HashKey*));
 
+                       Hash->LookupTable[Hash->nLookupTableItems - 1] = NULL;
                }
                else 
                        Hash->LookupTable[At->Position] = NULL;