fix memory leak

This commit is contained in:
Karl Seguin
2025-02-17 11:45:19 +08:00
parent b1c3de6518
commit b60a91f53c
2 changed files with 6 additions and 2 deletions

View File

@@ -178,7 +178,7 @@ pub const Session = struct {
fn deinit(self: *Session) void { fn deinit(self: *Session) void {
if (self.page) |*p| { if (self.page) |*p| {
p.end(); p.deinit();
} }
self.env.deinit(); self.env.deinit();
@@ -214,6 +214,10 @@ pub const Session = struct {
self.page = Page.init(self.allocator, self); self.page = Page.init(self.allocator, self);
return &self.page.?; return &self.page.?;
} }
pub fn currentPage(self: *Session) ?*Page {
return &(self.page orelse return null);
}
}; };
// Page navigates to an url. // Page navigates to an url.

View File

@@ -244,7 +244,7 @@ fn navigate(cmd: anytype) !void {
// Launch navigate, the page must have been created by a // Launch navigate, the page must have been created by a
// target.createTarget. // target.createTarget.
var p = cmd.session.page orelse return error.NoPage; var p = cmd.session.currentPage() orelse return error.NoPage;
state.execution_context_id += 1; state.execution_context_id += 1;
const aux_data = try std.fmt.allocPrint( const aux_data = try std.fmt.allocPrint(