| ... | ... | @@ -146,13 +146,12 @@ pub fn getEnvVarOwned(allocator: *mem.Allocator, key: []const u8) GetEnvVarOwned |
| 146 | 146 | error.Unexpected => return error.EnvironmentVariableNotFound, |
| 147 | 147 | else => |e| return e, |
| 148 | 148 | }; |
| 149 | | |
| 150 | 149 | if (result > buf.len) { |
| 151 | 150 | buf = try allocator.realloc(buf, result); |
| 152 | 151 | continue; |
| 153 | 152 | } |
| 154 | 153 | |
| 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 | 155 | error.DanglingSurrogateHalf => return error.InvalidUtf8, |
| 157 | 156 | error.ExpectedSecondSurrogateHalf => return error.InvalidUtf8, |
| 158 | 157 | error.UnexpectedSecondSurrogateHalf => return error.InvalidUtf8, |