fix slice alias crash after same document navigation

The WPT tests navigation-api/navigation-methods/navigate-history-push-same-url.html
crashed with a @memcpy arguments alias error.

It seems to be due to the reuse of the previous page.url string.
Forcing to duplicate it fixes the crash.
This commit is contained in:
Pierre Tachoire committed 2026-02-03 11:00:45 +01:00
1 parent 80f4c83b83
commit 8249725ae7
1 file changed
+8 -1
+8 -1
View File
@@ -271,9 +271,16 @@ pub fn navigateInner(
const committed = local.createPromiseResolver();
const finished = local.createPromiseResolver();
const new_url = try URL.resolve(arena, page.url, url, .{});
var new_url = try URL.resolve(arena, page.url, url, .{});
const is_same_document = URL.eqlDocument(new_url, page.url);
// In case of navigation to the same document, we force an url duplication.
// Keeping the same url generates a crash during WPT test navigate-history-push-same-url.html.
// When building a script's src, script's base and page url overlap.
if (is_same_document) {
new_url = try arena.dupeZ(u8, new_url);
}
const previous = self.getCurrentEntry();
switch (kind) {