From af834c6396a7355af5b9b47e145cec50de3d05a5 Mon Sep 17 00:00:00 2001 From: Rick L Bird Date: Tue, 10 May 2011 04:54:40 -0400 Subject: [PATCH] PennMUSH 1.8.3p12 Author: allthecoolkidshaveone Date: Wed Jan 13 09:36:05 2010 +0000 Issue 88: Possible fix for the hash table crash bug. Fixes #235 --- src/htab.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/htab.c b/src/htab.c index b0d1c36..0d8a347 100644 --- a/src/htab.c +++ b/src/htab.c @@ -612,14 +612,18 @@ hash_add(HASHTAB *htab, const char *key, void *hashdata) keycopy = mush_strdup(key, "hash.key"); - if (!hash_insert(htab, keycopy, hashdata)) { - first_offset = -1; - resize_calls = 0; - if (!real_hash_resize(htab, htab->hashsize, - (htab->hashfunc_offset + 1) % NHASH_MOD)) { - htab->entries -= 1; - return false; - } + + while (1) { + if (!hash_insert(htab, keycopy, hashdata)) { + first_offset = -1; + resize_calls = 0; + if (!real_hash_resize(htab, htab->hashsize, + (htab->hashfunc_offset + 1) % NHASH_MOD)) { + htab->entries -= 1; + return false; + } + } else + break; } return true; } -- 2.30.2