From d64bd30690b042177f084a5c17166777b953dd27 Mon Sep 17 00:00:00 2001 From: dimenus Date: Wed, 17 Jul 2019 10:58:32 -0500 Subject: fixed slice length in getEnvVarOwned --- std/process.zig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'std/process.zig') diff --git a/std/process.zig b/std/process.zig index b39c6e1196..c74e8c43be 100644 --- a/std/process.zig +++ b/std/process.zig @@ -146,13 +146,12 @@ pub fn getEnvVarOwned(allocator: *mem.Allocator, key: []const u8) GetEnvVarOwned error.Unexpected => return error.EnvironmentVariableNotFound, else => |e| return e, }; - if (result > buf.len) { buf = try allocator.realloc(buf, result); continue; } - return std.unicode.utf16leToUtf8Alloc(allocator, buf) catch |err| switch (err) { + return std.unicode.utf16leToUtf8Alloc(allocator, buf[0..result]) catch |err| switch (err) { error.DanglingSurrogateHalf => return error.InvalidUtf8, error.ExpectedSecondSurrogateHalf => return error.InvalidUtf8, error.UnexpectedSecondSurrogateHalf => return error.InvalidUtf8, -- cgit v1.2.3