[SETUPAPI] Don't let LZClose() reset error code
authorPierre Schweitzer <pierre@reactos.org>
Fri, 2 Nov 2018 08:34:25 +0000 (09:34 +0100)
committerPierre Schweitzer <pierre@reactos.org>
Fri, 2 Nov 2018 08:34:25 +0000 (09:34 +0100)
dll/win32/setupapi/queue.c

index e5919bb..4da2b5b 100644 (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