-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
path_from_handle using GetModuleFileNameW in wrong way #16
Comments
Many thanks for reporting the issue! |
I don't think the fix in f04ceff is correct, as calling I think, even setting the error code to zero beforehand is not guaranteed to work as the function might internally cause and handle an error reported via |
The chosen solution definitely doesn't work: #include <assert.h>
#include <windows.h>
int main()
{
SetLastError(42u);
GetLastError(); // <-- we depend on this resetting the error code (it doesn't)
assert(GetLastError() == ERROR_SUCCESS);
return 0;
} Leads to: Assertion failed!
Program: Z:\home\vanschig\git\novaui\thirdparty\test.exe
File: test.cpp, Line 8
Expression: GetLastError() == ERROR_SUCCESS
abnormal program termination |
boost\dll\detail\windows\path_from_handle.hpp
The problem here is that code doesn't analyze return code. If GetLastError() was dirty before a call this code will fail even if GetModuleFileNameW() will success. Yes, on success, GetModuleFileNameW() doesn't reset last error to ERROR_SUCCESS.
The text was updated successfully, but these errors were encountered: