https://git.reactos.org/?p=reactos.git;a=commitdiff;h=497a9c8087995039258c0afaa6ef4d9c546028fe
commit 497a9c8087995039258c0afaa6ef4d9c546028fe Author: Pierre Schweitzer <pie...@reactos.org> AuthorDate: Fri Nov 2 09:34:25 2018 +0100 Commit: Pierre Schweitzer <pie...@reactos.org> CommitDate: Fri Nov 2 09:34:25 2018 +0100 [SETUPAPI] Don't let LZClose() reset error code --- dll/win32/setupapi/queue.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dll/win32/setupapi/queue.c b/dll/win32/setupapi/queue.c index e5919bba5c..4da2b5b5b7 100644 --- a/dll/win32/setupapi/queue.c +++ b/dll/win32/setupapi/queue.c @@ -1068,6 +1068,7 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style, WCHAR TempPath[MAX_PATH]; WCHAR TempFile[MAX_PATH]; LONG lRes; + DWORD dwLastError; #endif TRACE("copy %s to %s style 0x%x\n",debugstr_w(source),debugstr_w(target),style); @@ -1090,11 +1091,16 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style, if (!GetTempFileNameW(TempPath, L"", 0, TempFile)) { + dwLastError = GetLastError(); + ERR("GetTempFileNameW(%s) error\n", debugstr_w(TempPath)); /* Close the source handle */ LZClose(hSource); + /* Restore error condition triggered by GetTempFileNameW */ + SetLastError(dwLastError); + return FALSE; } @@ -1102,6 +1108,8 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style, hTemp = LZOpenFileW(TempFile, &OfStruct, OF_CREATE); if (hTemp < 0) { + dwLastError = GetLastError(); + ERR("LZOpenFileW(2) error %d %s\n", (int)hTemp, debugstr_w(TempFile)); /* Close the source handle */ @@ -1110,11 +1118,16 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style, /* Delete temp file if an error is signaled */ DeleteFileW(TempFile); + /* Restore error condition triggered by LZOpenFileW */ + SetLastError(dwLastError); + return FALSE; } lRes = LZCopy(hSource, hTemp); + dwLastError = GetLastError(); + LZClose(hSource); LZClose(hTemp); @@ -1125,6 +1138,9 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style, /* Delete temp file if copy was not successful */ DeleteFileW(TempFile); + /* Restore error condition triggered by LZCopy */ + SetLastError(dwLastError); + return FALSE; } #endif