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
146146 error.Unexpected => return error.EnvironmentVariableNotFound,
147147 else => |e| return e,
148148 };
149
150149 if (result > buf.len) {
151150 buf = try allocator.realloc(buf, result);
152151 continue;
153152 }
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) {
156155 error.DanglingSurrogateHalf => return error.InvalidUtf8,
157156 error.ExpectedSecondSurrogateHalf => return error.InvalidUtf8,
158157 error.UnexpectedSecondSurrogateHalf => return error.InvalidUtf8,