| ... | ... | @@ -994,15 +994,15 @@ int os_self_exe_path(Buf *out_path) { |
| 994 | 994 | int ret1 = _NSGetExecutablePath(nullptr, &u32_len); |
| 995 | 995 | assert(ret1 != 0); |
| 996 | 996 | |
| 997 | | // Make a buffer having room for the temp path. |
| 998 | 997 | Buf *tmp = buf_alloc_fixed(u32_len); |
| 999 | 998 | |
| 1000 | 999 | // Fill the executable path. |
| 1001 | 1000 | int ret2 = _NSGetExecutablePath(buf_ptr(tmp), &u32_len); |
| 1002 | 1001 | assert(ret2 == 0); |
| 1003 | 1002 | |
| 1004 | | // Resolve the real path from that. |
| 1005 | | buf_resize(out_path, PATH_MAX); |
| 1003 | // According to libuv project, PATH_MAX*2 works around a libc bug where |
| 1004 | // the resolved path is sometimes bigger than PATH_MAX. |
| 1005 | buf_resize(out_path, PATH_MAX*2); |
| 1006 | 1006 | char *real_path = realpath(buf_ptr(tmp), buf_ptr(out_path)); |
| 1007 | 1007 | if (!real_path) { |
| 1008 | 1008 | buf_init_from_buf(out_path, tmp); |