From cd4676a2338430d9e424f297b8b576143c5be180 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 18 Jun 2018 12:54:03 -0400 Subject: [PATCH] stage1: update darwin code to workaround old libc bug See #1128 --- src/os.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/os.cpp b/src/os.cpp index 14e9effb1e..b7d2fd1de0 100644 --- a/src/os.cpp +++ b/src/os.cpp @@ -994,15 +994,15 @@ int os_self_exe_path(Buf *out_path) { int ret1 = _NSGetExecutablePath(nullptr, &u32_len); assert(ret1 != 0); - // Make a buffer having room for the temp path. Buf *tmp = buf_alloc_fixed(u32_len); // Fill the executable path. int ret2 = _NSGetExecutablePath(buf_ptr(tmp), &u32_len); assert(ret2 == 0); - // Resolve the real path from that. - buf_resize(out_path, PATH_MAX); + // According to libuv project, PATH_MAX*2 works around a libc bug where + // the resolved path is sometimes bigger than PATH_MAX. + buf_resize(out_path, PATH_MAX*2); char *real_path = realpath(buf_ptr(tmp), buf_ptr(out_path)); if (!real_path) { buf_init_from_buf(out_path, tmp);