Commit 4bee238c authored by Ivan Pozdeev's avatar Ivan Pozdeev

GetModuleFileName() doesn't reset last error on success

parent 4af3ca4e
...@@ -124,8 +124,10 @@ private: ...@@ -124,8 +124,10 @@ private:
if (m) if (m)
{ {
wchar_t path[MAX_PATH]; wchar_t path[MAX_PATH];
size_t sz = GetModuleFileNameW(m, path, sizeof(path)); const size_t path_size = sizeof(path)/sizeof(*path);
if (sz > 0 && ERROR_SUCCESS == GetLastError()) size_t sz = GetModuleFileNameW(m, path, path_size);
/* Don't handle paths longer than MAX_PATH until that becomes a real issue */
if (sz > 0 && sz < path_size)
{ {
wchar_t* s = wcsrchr(path, L'\\'); wchar_t* s = wcsrchr(path, L'\\');
if (s) if (s)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment