From 0fe727c7eb593cd264f1fcdc36cd37636613fddd Mon Sep 17 00:00:00 2001 From: Simon Hartcher Date: Wed, 23 Apr 2025 16:39:04 +1000 Subject: [PATCH] fix: xml memory leaks using arena --- src/aws.zig | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/aws.zig b/src/aws.zig index e8adb43..79f4adf 100644 --- a/src/aws.zig +++ b/src/aws.zig @@ -646,7 +646,13 @@ pub fn Request(comptime request_action: anytype) type { // } // // Big thing is that requestid, which we'll need to fetch "manually" - const xml_options = xml_shaper.ParseOptions{ .allocator = options.client.allocator, .elementToParse = findResult }; + var arena = ArenaAllocator.init(options.client.allocator); + + const xml_options = xml_shaper.ParseOptions{ + .allocator = arena.allocator(), + .elementToParse = findResult, + }; + var body: []const u8 = result.body; var free_body = false; if (result.body.len < 20) { @@ -677,12 +683,13 @@ pub fn Request(comptime request_action: anytype) type { }; return try FullResponseType.init(.{ - .arena = ArenaAllocator.init(options.client.allocator), + .arena = arena, .response = parsed.parsed_value, .request_id = request_id, .raw_parsed = .{ .xml = parsed }, }); } + const ServerResponseTypes = struct { NormalResponse: type, RawResponse: type,