93115576408d — Leonard Ritter 1 year, 2 months ago
* fixed potential hashing of uninitialized values in the erase functions of `Map` and `Set`
2 files changed, 2 insertions(+), 4 deletions(-)

M lib/scopes/Map.sc
M lib/scopes/Set.sc
M lib/scopes/Map.sc +1 -2
@@ 144,8 144,7 @@ typedef Map < Struct
                 let atvalue = (self._values @ index)
                 let prev_key = (self._keys @ index_prev)
                 let prev_value = (self._values @ index_prev)
-                let pd = (keydistance ((hash atkey) as u64) index mask)
-                if ((pd == 0) or (not (valid-slot? self index)))
+                if ((not (valid-slot? self index)) or ((keydistance ((hash atkey) as u64) index mask) == 0))
                     unset-slot self index_prev
                     merge done
                 swap atkey prev_key

          
M lib/scopes/Set.sc +1 -2
@@ 138,8 138,7 @@ typedef Set < Struct
                 let index_prev = (prevpos index mask)
                 let atkey = (self._keys @ index)
                 let prev_key = (self._keys @ index_prev)
-                let pd = (keydistance ((hash atkey) as u64) index mask)
-                if ((pd == 0) or (not (valid-slot? self index)))
+                if ((not (valid-slot? self index)) or ((keydistance ((hash atkey) as u64) index mask) == 0))
                     unset-slot self index_prev
                     merge done
                 swap atkey prev_key