Skip to content

Commit 102cf34

Browse files
committed
LibWeb: Recompute targetStep once more in "apply the history step"
This is an ad-hoc change to account for the fact that we may run arbitrary code while waiting for the tasks in this function to complete. Same exact idea as ac48222, once again.
1 parent b82e34e commit 102cf34

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,10 @@ TraversableNavigable::HistoryStepResult TraversableNavigable::apply_the_history_
798798
// 16. Let completedNonchangingJobs be 0.
799799
IGNORE_USE_IN_ESCAPING_LAMBDA auto completed_non_changing_jobs = 0u;
800800

801+
// AD-HOC: We re-compute targetStep here, since it might have changed since the last time we computed it.
802+
// This can happen if navigables are destroyed while we wait for tasks to complete.
803+
target_step = get_the_used_step(step);
804+
801805
// 17. Let (scriptHistoryLength, scriptHistoryIndex) be the result of getting the history object length and index given traversable and targetStep.
802806
auto length_and_index = get_the_history_object_length_and_index(target_step);
803807
IGNORE_USE_IN_ESCAPING_LAMBDA auto script_history_length = length_and_index.script_history_length;

0 commit comments

Comments
 (0)