mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Merge pull request #1721 from lightpanda-io/fix_mcp_unintialized_memory
Ensure that mcp.Server is correctly initialized
This commit is contained in:
@@ -24,22 +24,29 @@ mutex: std.Thread.Mutex = .{},
|
|||||||
aw: std.io.Writer.Allocating,
|
aw: std.io.Writer.Allocating,
|
||||||
|
|
||||||
pub fn init(allocator: std.mem.Allocator, app: *App, writer: *std.io.Writer) !*Self {
|
pub fn init(allocator: std.mem.Allocator, app: *App, writer: *std.io.Writer) !*Self {
|
||||||
|
const http_client = try app.http.createClient(allocator);
|
||||||
|
errdefer http_client.deinit();
|
||||||
|
|
||||||
|
const notification = try lp.Notification.init(allocator);
|
||||||
|
errdefer notification.deinit();
|
||||||
|
|
||||||
const self = try allocator.create(Self);
|
const self = try allocator.create(Self);
|
||||||
errdefer allocator.destroy(self);
|
errdefer allocator.destroy(self);
|
||||||
|
|
||||||
self.allocator = allocator;
|
var browser = try lp.Browser.init(app, .{ .http_client = http_client });
|
||||||
self.app = app;
|
errdefer browser.deinit();
|
||||||
self.writer = writer;
|
|
||||||
self.aw = .init(allocator);
|
|
||||||
|
|
||||||
self.http_client = try app.http.createClient(allocator);
|
self.* = .{
|
||||||
errdefer self.http_client.deinit();
|
.allocator = allocator,
|
||||||
|
.app = app,
|
||||||
self.notification = try .init(allocator);
|
.writer = writer,
|
||||||
errdefer self.notification.deinit();
|
.browser = browser,
|
||||||
|
.aw = .init(allocator),
|
||||||
self.browser = try lp.Browser.init(app, .{ .http_client = self.http_client });
|
.http_client = http_client,
|
||||||
errdefer self.browser.deinit();
|
.notification = notification,
|
||||||
|
.session = undefined,
|
||||||
|
.page = undefined,
|
||||||
|
};
|
||||||
|
|
||||||
self.session = try self.browser.newSession(self.notification);
|
self.session = try self.browser.newSession(self.notification);
|
||||||
self.page = try self.session.createPage();
|
self.page = try self.session.createPage();
|
||||||
|
|||||||
Reference in New Issue
Block a user