[SETUPAPI] Don't let LZClose() reset error code

This commit is contained in:
Pierre Schweitzer 2018-11-02 09:34:25 +01:00
parent 8236bb8f38
commit 497a9c8087
No known key found for this signature in database
GPG key ID: 7545556C3D585B0B

View file

@ -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