Skip to content

Commit b60a91f

Browse files
committed
fix memory leak
1 parent b1c3de6 commit b60a91f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/browser/browser.zig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ pub const Session = struct {
178178

179179
fn deinit(self: *Session) void {
180180
if (self.page) |*p| {
181-
p.end();
181+
p.deinit();
182182
}
183183

184184
self.env.deinit();
@@ -214,6 +214,10 @@ pub const Session = struct {
214214
self.page = Page.init(self.allocator, self);
215215
return &self.page.?;
216216
}
217+
218+
pub fn currentPage(self: *Session) ?*Page {
219+
return &(self.page orelse return null);
220+
}
217221
};
218222

219223
// Page navigates to an url.

src/cdp/page.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ fn navigate(cmd: anytype) !void {
244244

245245
// Launch navigate, the page must have been created by a
246246
// target.createTarget.
247-
var p = cmd.session.page orelse return error.NoPage;
247+
var p = cmd.session.currentPage() orelse return error.NoPage;
248248
state.execution_context_id += 1;
249249

250250
const aux_data = try std.fmt.allocPrint(

0 commit comments

Comments
 (0)