fix memory leak when AWS_ENDPOINT_URL is used
All checks were successful
AWS-Zig Build / build-zig-0.11.0-amd64-host (push) Successful in 7m4s

This commit is contained in:
Emil Lerch 2023-09-15 09:05:53 -07:00
parent 5d13b48da6
commit db19041b96
Signed by: lobo
GPG Key ID: A7B62D657EF764F8

View File

@ -304,8 +304,13 @@ fn getEnvironmentVariable(allocator: std.mem.Allocator, key: []const u8) !?[]con
pub var endpoint_override: ?[]const u8 = null; pub var endpoint_override: ?[]const u8 = null;
fn endpointForRequest(allocator: std.mem.Allocator, service: []const u8, request: HttpRequest, options: Options) !EndPoint { fn endpointForRequest(allocator: std.mem.Allocator, service: []const u8, request: HttpRequest, options: Options) !EndPoint {
const environment_override = endpoint_override orelse try getEnvironmentVariable(allocator, "AWS_ENDPOINT_URL"); if (endpoint_override) |override| {
const uri = try allocator.dupe(u8, override);
return endPointFromUri(allocator, uri, request.path);
}
const environment_override = try getEnvironmentVariable(allocator, "AWS_ENDPOINT_URL");
if (environment_override) |override| { if (environment_override) |override| {
defer allocator.free(override);
const uri = try allocator.dupe(u8, override); const uri = try allocator.dupe(u8, override);
return endPointFromUri(allocator, uri, request.path); return endPointFromUri(allocator, uri, request.path);
} }