From 8249725ae78d4d2af5b2a8aec6a1694a8d335686 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Tue, 3 Feb 2026 10:59:37 +0100 Subject: [PATCH] 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. --- src/browser/webapi/navigation/Navigation.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/browser/webapi/navigation/Navigation.zig b/src/browser/webapi/navigation/Navigation.zig index d3a6887e..14a11183 100644 --- a/src/browser/webapi/navigation/Navigation.zig +++ b/src/browser/webapi/navigation/Navigation.zig @@ -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) {