mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-05 16:41:52 +00:00
LibWeb: Don't crash on named property access on detached window
In WindowProxy.[[Get]] it's not guaranteed that the current principal global object has an associated document at the moment. This may happen if a script is continuing to execute while a navigation has been initiated. Because of that, we can't blindly dereference the active document pointer, so this patch adds a null check.
This commit is contained in:
parent
456608cf03
commit
2eea8894a1
Notes:
github-actions[bot]
2025-05-30 08:14:45 +00:00
Author: https://github.com/awesomekling
Commit: 2eea8894a1
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4922
Reviewed-by: https://github.com/ADKaster
3 changed files with 13 additions and 13 deletions
|
@ -161,7 +161,7 @@ JS::ThrowCompletionOr<JS::Value> WindowProxy::internal_get(JS::PropertyKey const
|
|||
// 1. Let W be the value of the [[Window]] internal slot of this.
|
||||
|
||||
// 2. Check if an access between two browsing contexts should be reported, given the current principal global object's browsing context, W's browsing context, P, and the current principal settings object.
|
||||
check_if_access_between_two_browsing_contexts_should_be_reported(*as<Window>(current_principal_global_object()).browsing_context(), m_window->browsing_context(), property_key, current_principal_settings_object());
|
||||
check_if_access_between_two_browsing_contexts_should_be_reported(as<Window>(current_principal_global_object()).browsing_context(), m_window->browsing_context(), property_key, current_principal_settings_object());
|
||||
|
||||
// 3. If IsPlatformObjectSameOrigin(W) is true, then return ? OrdinaryGet(this, P, Receiver).
|
||||
// NOTE: this is passed rather than W as OrdinaryGet and CrossOriginGet will invoke the [[GetOwnProperty]] internal method.
|
||||
|
@ -182,7 +182,7 @@ JS::ThrowCompletionOr<bool> WindowProxy::internal_set(JS::PropertyKey const& pro
|
|||
// 1. Let W be the value of the [[Window]] internal slot of this.
|
||||
|
||||
// 2. Check if an access between two browsing contexts should be reported, given the current principal global object's browsing context, W's browsing context, P, and the current principal settings object.
|
||||
check_if_access_between_two_browsing_contexts_should_be_reported(*as<Window>(current_principal_global_object()).browsing_context(), m_window->browsing_context(), property_key, current_principal_settings_object());
|
||||
check_if_access_between_two_browsing_contexts_should_be_reported(as<Window>(current_principal_global_object()).browsing_context(), m_window->browsing_context(), property_key, current_principal_settings_object());
|
||||
|
||||
// 3. If IsPlatformObjectSameOrigin(W) is true, then:
|
||||
if (is_platform_object_same_origin(*m_window)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue