authorgravatar for ryan.saunderson88@gmail.comdimenus <ryan.saunderson88@gmail.com> 2019-07-17 10:58:32-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-07-17 12:13:50-04:00
logd64bd30690b042177f084a5c17166777b953dd27
treea3d5fee8568460b8af36337ff25a8016c55b39b2
parentc0b4121ff2d31b2ef37e480eec18f0bd063d7a2d

fixed slice length in getEnvVarOwned


1 files changed, 1 insertions(+), 2 deletions(-)

std/process.zig+1-2
...@@ -146,13 +146,12 @@ pub fn getEnvVarOwned(allocator: *mem.Allocator, key: []const u8) GetEnvVarOwned...@@ -146,13 +146,12 @@ pub fn getEnvVarOwned(allocator: *mem.Allocator, key: []const u8) GetEnvVarOwned
146 error.Unexpected => return error.EnvironmentVariableNotFound,146 error.Unexpected => return error.EnvironmentVariableNotFound,
147 else => |e| return e,147 else => |e| return e,
148 };148 };
149
150 if (result > buf.len) {149 if (result > buf.len) {
151 buf = try allocator.realloc(buf, result);150 buf = try allocator.realloc(buf, result);
152 continue;151 continue;
153 }152 }
154153
155 return std.unicode.utf16leToUtf8Alloc(allocator, buf) catch |err| switch (err) {154 return std.unicode.utf16leToUtf8Alloc(allocator, buf[0..result]) catch |err| switch (err) {
156 error.DanglingSurrogateHalf => return error.InvalidUtf8,155 error.DanglingSurrogateHalf => return error.InvalidUtf8,
157 error.ExpectedSecondSurrogateHalf => return error.InvalidUtf8,156 error.ExpectedSecondSurrogateHalf => return error.InvalidUtf8,
158 error.UnexpectedSecondSurrogateHalf => return error.InvalidUtf8,157 error.UnexpectedSecondSurrogateHalf => return error.InvalidUtf8,