From 93c461fcc055cef8637a4175582cb99eff2c61a6 Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Sat, 24 Jul 2021 00:23:58 -0700 Subject: [PATCH] fix leaked memory on errors due to sentinal on concatenated data --- src/awshttp.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/awshttp.zig b/src/awshttp.zig index 045a8cf..11b7e44 100644 --- a/src/awshttp.zig +++ b/src/awshttp.zig @@ -972,12 +972,12 @@ const RequestContext = struct { pub fn appendToBody(self: *Self, fragment: []const u8) !void { var orig_body: []const u8 = ""; if (self.body) |b| { - orig_body = try self.allocator.dupeZ(u8, b); + orig_body = try self.allocator.dupe(u8, b); self.allocator.free(b); self.body = null; } defer self.allocator.free(orig_body); - self.body = try std.fmt.allocPrintZ(self.allocator, "{s}{s}", .{ orig_body, fragment }); + self.body = try std.fmt.allocPrint(self.allocator, "{s}{s}", .{ orig_body, fragment }); } pub fn addHeader(self: *Self, name: []const u8, value: []const u8) !void {