Fix bounds check for map bogus keys in maptools (#77283)

Prevents rare cases of map merge eating your map
This commit is contained in:
oranges
2023-08-02 09:41:07 -04:00
committed by GitHub
parent 6f5b64834c
commit 6fc59fdbae
+1 -1
View File
@@ -95,7 +95,7 @@ class DMM:
# last-second handling of bogus keys to help prevent and fix broken maps
self._ensure_free_keys(0)
max_key = max_key_for(self.key_length)
bad_keys = {key: 0 for key in self.dictionary.keys() if key > max_key}
bad_keys = {key: 0 for key in self.dictionary.keys() if key >= max_key}
if bad_keys:
print(f"Warning: fixing {len(bad_keys)} overflowing keys")
for k in bad_keys: