Commit 1955610c authored by Albert Gräf's avatar Albert Gräf
Browse files

Fix improper string access in pd_getdirname on Mac.

parent e2b3cc4a
...@@ -848,9 +848,10 @@ t_symbol *pd_getdirname(void) ...@@ -848,9 +848,10 @@ t_symbol *pd_getdirname(void)
buf[len] = '\0'; buf[len] = '\0';
sys_unbashfilename(buf, buf); sys_unbashfilename(buf, buf);
#elif defined(__APPLE__) #elif defined(__APPLE__)
len = sizeof(buf); int ret;
_NSGetExecutablePath(buf, &len); len = sizeof(buf); buf[0] = '\0';
if (len != -1) buf[len] = '\0'; ret = _NSGetExecutablePath(buf, &len);
if (ret) len = -1;
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
len = (ssize_t)(readlink("/proc/curproc/file", buf, sizeof(buf)-1)); len = (ssize_t)(readlink("/proc/curproc/file", buf, sizeof(buf)-1));
if (len != -1) buf[len] = '\0'; if (len != -1) buf[len] = '\0';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment