summaryrefslogtreecommitdiff
path: root/src/dict.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dict.c')
-rw-r--r--src/dict.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/dict.c b/src/dict.c
index 106467ef7..93e6c39a7 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -871,6 +871,10 @@ unsigned long dictScan(dict *d,
if (dictSize(d) == 0) return 0;
+ /* Having a safe iterator means no rehashing can happen, see _dictRehashStep.
+ * This is needed in case the scan callback tries to do dictFind or alike. */
+ d->iterators++;
+
if (!dictIsRehashing(d)) {
t0 = &(d->ht[0]);
m0 = t0->sizemask;
@@ -937,6 +941,9 @@ unsigned long dictScan(dict *d,
} while (v & (m0 ^ m1));
}
+ /* undo the ++ at the top */
+ d->iterators--;
+
return v;
}