Merge pull request #1153 from lightpanda-io/normalized_specifier_lifetime
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled

Fix a potential segfault on log message for failing to load module
This commit is contained in:
Karl Seguin
2025-10-16 15:01:50 +08:00
committed by GitHub

View File

@@ -262,7 +262,7 @@ pub fn module(self: *Context, comptime want_result: bool, src: []const u8, url:
const owned_specifier = try self.arena.dupeZ(u8, normalized_specifier); const owned_specifier = try self.arena.dupeZ(u8, normalized_specifier);
gop.key_ptr.* = owned_specifier; gop.key_ptr.* = owned_specifier;
gop.value_ptr.* = .{}; gop.value_ptr.* = .{};
try self.script_manager.?.getModule(owned_specifier, src); try self.script_manager.?.getModule(owned_specifier, url);
} }
} }
} }
@@ -1171,7 +1171,7 @@ fn _resolveModuleCallback(self: *Context, referrer: v8.Module, specifier: []cons
}; };
const normalized_specifier = try self.script_manager.?.resolveSpecifier( const normalized_specifier = try self.script_manager.?.resolveSpecifier(
self.call_arena, self.arena, // might need to survive until the module is loaded
specifier, specifier,
referrer_path, referrer_path,
); );
@@ -1207,7 +1207,7 @@ fn _resolveModuleCallback(self: *Context, referrer: v8.Module, specifier: []cons
const entry = self.module(true, fetch_result.src(), normalized_specifier, true) catch |err| { const entry = self.module(true, fetch_result.src(), normalized_specifier, true) catch |err| {
log.warn(.js, "compile resolved module", .{ log.warn(.js, "compile resolved module", .{
.specifier = specifier, .specifier = normalized_specifier,
.stack = try_catch.stack(self.call_arena) catch null, .stack = try_catch.stack(self.call_arena) catch null,
.src = try_catch.sourceLine(self.call_arena) catch "err", .src = try_catch.sourceLine(self.call_arena) catch "err",
.line = try_catch.sourceLineNumber() orelse 0, .line = try_catch.sourceLineNumber() orelse 0,