Returned path length is off by one
DanielSWolf opened this issue · comments
According to documentation, the path length returned by wai_getExecutablePath
is the actual number of characters without a terminating zero byte. Actually, at least on Windows, the value returned includes the trailing zero byte.
This can lead to bugs. For instance, when creating a string like this:
std::string path(buffer, length);
The result is a string with length length
that (wrongly) contains a zero character as part of the string.
I see two possible solutions. If all platforms consistently add the zero byte, just the documentation needs to be changed. Otherwise, the individual implementations should be changed to behave consistently.
Consider this a duplicate.
Sorry for the inconvenience