From c23ea494eabd1695b8c43f00bff4b5820c0cd56c Mon Sep 17 00:00:00 2001 From: Chris Robinson <chris.kcat@gmail.com> Date: Sun, 11 Nov 2018 22:19:32 -0800 Subject: Fix getting the process binary for FreeBSD or macOS --- Alc/helpers.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'Alc/helpers.cpp') diff --git a/Alc/helpers.cpp b/Alc/helpers.cpp index 864278bb..0505c729 100644 --- a/Alc/helpers.cpp +++ b/Alc/helpers.cpp @@ -484,21 +484,19 @@ PathNamePair GetProcBinary() { pathname.resize(pathlen + 1); sysctl(mib, 4, pathname.data(), &pathlen, nullptr, 0); - pathname[pathlen] = 0; + pathname.resize(pathlen); } #endif #ifdef HAVE_PROC_PIDPATH if(pathname.empty()) { - const pid_t pid = getpid(); - char procpath[PROC_PIDPATHINFO_MAXSIZE]; - int ret; - - ret = proc_pidpath(pid, procpath, sizeof(procpath)); + char procpath[PROC_PIDPATHINFO_MAXSIZE]{}; + const pid_t pid{getpid()}; + const int ret{proc_pidpath(pid, procpath, sizeof(procpath))}; if(ret < 1) - WARN("proc_pidpath(%d, ...) failed: %s\n", pid, strerror(errno)); + ERR("proc_pidpath(%d, ...) failed: %s\n", pid, strerror(errno)); else - pathname.append(procpath, procpath+strlen(procpath)); + pathname.insert(pathname.end(), procpath, procpath+strlen(procpath)); } #endif if(pathname.empty()) -- cgit v1.2.3