cdp: fix memory leak in msg parsing of the JSON

Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
Francis Bouvier
2024-11-09 03:25:42 +01:00
parent f60fcbec04
commit ed3a464843
10 changed files with 131 additions and 46 deletions

View File

@@ -23,6 +23,7 @@ const Ctx = server.Ctx;
const cdp = @import("cdp.zig");
const result = cdp.result;
const IncomingMessage = @import("msg.zig").IncomingMessage;
const Input = @import("msg.zig").Input;
const log = std.log.scoped(.cdp);
@@ -52,7 +53,8 @@ fn enable(
_: *Ctx,
) ![]const u8 {
// input
const input = try msg.getInput(alloc, void);
const input = try Input(void).get(alloc, msg);
defer input.deinit();
log.debug("Req > id {d}, method {s}", .{ input.id, "network.enable" });
return result(alloc, input.id, null, null, input.sessionId);
@@ -65,7 +67,8 @@ fn setCacheDisabled(
_: *Ctx,
) ![]const u8 {
// input
const input = try msg.getInput(alloc, void);
const input = try Input(void).get(alloc, msg);
defer input.deinit();
log.debug("Req > id {d}, method {s}", .{ input.id, "network.setCacheDisabled" });
return result(alloc, input.id, null, null, input.sessionId);