From e396deda94e9c984f8e1ae69e4fa423f8388483b Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 20 Sep 2016 17:22:30 +0200 Subject: [PATCH] dict.c: fix dictGenericDelete() return ASAP condition. Recently we moved the "return ASAP" condition for the Delete() function from checking .size to checking .used, which is smarter, however while testing the first table alone always works to ensure the dict is totally emtpy, when we test the .size field, testing .used requires testing both T0 and T1, since a rehashing could be in progress. --- src/dict.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dict.c b/src/dict.c index 04dfae6cc..b9b2390f1 100644 --- a/src/dict.c +++ b/src/dict.c @@ -415,7 +415,8 @@ static dictEntry *dictGenericDelete(dict *d, const void *key, int nofree) { dictEntry *he, *prevHe; int table; - if (d->ht[0].used == 0) return NULL; + if (d->ht[0].used == 0 && d->ht[1].used == 0) return NULL; + if (dictIsRehashing(d)) _dictRehashStep(d); h = dictHashKey(d, key);