mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-23 04:55:15 +00:00
LibJS: Dereference intrinsic accessor before deleting it
The iterator used to find an intrinsic accessor is used after calling `HashMap.remove()` on it, which works for our current implementation but will fall apart when you consider that modifications to the hash map might invalidate all existing iterators that came from it, as many implementations do. Since we're aiming to replace our `HashTable` implementation with something new, let's fix this first :^)
This commit is contained in:
parent
bc76cba7c2
commit
8f015a18a5
Notes:
sideshowbarker
2024-07-17 05:02:42 +09:00
Author: https://github.com/gmta Commit: https://github.com/SerenityOS/serenity/commit/8f015a18a5 Pull-request: https://github.com/SerenityOS/serenity/pull/17472 Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/davidot ✅
1 changed files with 5 additions and 4 deletions
|
@ -1007,12 +1007,13 @@ static Optional<Object::IntrinsicAccessor> find_intrinsic_accessor(Object const*
|
|||
if (intrinsics == s_intrinsics.end())
|
||||
return {};
|
||||
|
||||
auto accessor = intrinsics->value.find(property_key.as_string());
|
||||
if (accessor == intrinsics->value.end())
|
||||
auto accessor_iterator = intrinsics->value.find(property_key.as_string());
|
||||
if (accessor_iterator == intrinsics->value.end())
|
||||
return {};
|
||||
|
||||
intrinsics->value.remove(accessor);
|
||||
return move(accessor->value);
|
||||
auto accessor = accessor_iterator->value;
|
||||
intrinsics->value.remove(accessor_iterator);
|
||||
return accessor;
|
||||
}
|
||||
|
||||
Optional<ValueAndAttributes> Object::storage_get(PropertyKey const& property_key) const
|
||||
|
|
Loading…
Add table
Reference in a new issue