From 276598346a1f04bcfbe4982ea3c766aa79cad681 Mon Sep 17 00:00:00 2001 From: Loris Cro Date: Sat, 3 Oct 2020 12:03:22 +0200 Subject: [PATCH] provide the full buffer length to _NSGetExecutablePath Signed-off-by: Loris Cro --- lib/std/fs.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/fs.zig b/lib/std/fs.zig index 51d40caf56..1d98c03c5c 100644 --- a/lib/std/fs.zig +++ b/lib/std/fs.zig @@ -2193,7 +2193,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 { // Note that _NSGetExecutablePath() will return "a path" to // the executable not a "real path" to the executable. var symlink_path_buf: [MAX_PATH_BYTES:0]u8 = undefined; - var u32_len: u32 = MAX_PATH_BYTES; + var u32_len: u32 = MAX_PATH_BYTES + 1; // include the sentinel const rc = std.c._NSGetExecutablePath(&symlink_path_buf, &u32_len); if (rc != 0) return error.NameTooLong;