Skip to content

Commit 9eff97f

Browse files
Correct the executable path for osx (#170)
on osx, the executable path was using the size variable, however this wasn't holding the number of bytes put in the buffer, it instead just is used to output the required size if there was not enough. As a result, the string had nulls in it. Later when it was concatenated with an extension for traces, the nulls meant that the final path was just the binary name which was overwritten. since PATH_MAX is used as the buffer size, we don't need to look at the space required as it should be PATH_MAX or less by definition.
1 parent defb7e9 commit 9eff97f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

tests/test_util/executable_path.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ std::string get_executable_path() {
5151
std::array<char, PATH_MAX> buffer{};
5252
uint32_t size = buffer.size();
5353
if (::_NSGetExecutablePath(buffer.data(), &size) == 0) {
54-
return {buffer.data(), size};
54+
return {buffer.data()};
5555
}
5656
throw std::system_error(std::make_error_code(std::errc::no_such_file_or_directory),
5757
"Could not get executable path");

0 commit comments

Comments
 (0)