From 1955610c4b1d3af7daf512baeb443d9ca0b6d364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Gr=C3=A4f?= <aggraef@gmail.com> Date: Thu, 18 Jul 2019 11:19:35 +0200 Subject: [PATCH] Fix improper string access in pd_getdirname on Mac. --- pd/src/s_path.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pd/src/s_path.c b/pd/src/s_path.c index 152bd4149..321757a5b 100644 --- a/pd/src/s_path.c +++ b/pd/src/s_path.c @@ -848,9 +848,10 @@ t_symbol *pd_getdirname(void) buf[len] = '\0'; sys_unbashfilename(buf, buf); #elif defined(__APPLE__) - len = sizeof(buf); - _NSGetExecutablePath(buf, &len); - if (len != -1) buf[len] = '\0'; + int ret; + len = sizeof(buf); buf[0] = '\0'; + ret = _NSGetExecutablePath(buf, &len); + if (ret) len = -1; #elif defined(__FreeBSD__) len = (ssize_t)(readlink("/proc/curproc/file", buf, sizeof(buf)-1)); if (len != -1) buf[len] = '\0'; -- GitLab