Mercurial > code
changeset 610:2e93742789fd
Misc: OpenBSD fix for executable
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sat, 01 Jul 2017 07:08:34 +0200 |
parents | 40f6b66ec70a |
children | beef249c796c |
files | misc/executable.cpp |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/misc/executable.cpp Sat Jul 01 06:33:51 2017 +0200 +++ b/misc/executable.cpp Sat Jul 01 07:08:34 2017 +0200 @@ -85,13 +85,14 @@ result = path; #elif defined(__OpenBSD__) char **paths, path[PATH_MAX + 1] = {0}; - int length, mib[] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV }; + int mib[] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV }; + size_t length = 0; - if (sysctl(mib, 4, nullptr, &length, nullptr, 0) < 0) + if (sysctl(mib, 4, 0, &length, 0, 0) < 0) throw std::runtime_error(std::strerror(errno)); - if ((paths = static_cast<char**>(std::malloc(length))) == nullptr) + if (!(paths = static_cast<char**>(std::malloc(length)))) throw std::runtime_error(std::strerror(errno)); - if (sysctl(mib, 4, paths, &length, nullptr, 0) < 0) { + if (sysctl(mib, 4, paths, &length, 0, 0) < 0) { std::free(paths); throw std::runtime_error(std::strerror(errno)); } @@ -100,7 +101,6 @@ result = path; std::free(paths); - std::free(path); #endif return result;