From d9a936db09327e2b9a08ff8834e378b3941d362c Mon Sep 17 00:00:00 2001 From: Drew Galbraith Date: Sat, 25 Nov 2023 11:13:09 -0800 Subject: [PATCH] [Glacier] Fix div0 bug when calling .Contains on empty hashmap. --- lib/glacier/container/hash_map.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/glacier/container/hash_map.h b/lib/glacier/container/hash_map.h index a101bda..e8a9eec 100644 --- a/lib/glacier/container/hash_map.h +++ b/lib/glacier/container/hash_map.h @@ -92,6 +92,9 @@ const V& HashMap::at(const K& key) const { template bool HashMap::Contains(const K& key) const { + if (data_.size() == 0) { + return false; + } uint64_t hc = H()(key); auto& ll = data_[hc % data_.size()];