]> wimlib.net Git - wimlib/commitdiff
win32_delete_file_wrapper(): Check for INVALID_FILE_ATTRIBUTES
authorEric Biggers <ebiggers3@gmail.com>
Mon, 13 Jan 2014 20:35:12 +0000 (14:35 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 13 Jan 2014 20:35:12 +0000 (14:35 -0600)
src/win32_apply.c

index 9eb8bad005f9fa6b2ef23d4fcee6e5be835d2f25..df74519ddc4dcfc0ca14cbb38e518b63ac9a30f1 100644 (file)
@@ -158,15 +158,17 @@ error:
 static BOOL
 win32_delete_file_wrapper(const wchar_t *path)
 {
-       DWORD attrib;
        DWORD err;
+       DWORD attrib;
 
        if (DeleteFile(path))
                return TRUE;
 
        err = GetLastError();
        attrib = GetFileAttributes(path);
-       if (attrib & FILE_ATTRIBUTE_READONLY) {
+       if ((attrib != INVALID_FILE_ATTRIBUTES) &&
+           (attrib & FILE_ATTRIBUTE_READONLY))
+       {
                /* Try again with FILE_ATTRIBUTE_READONLY cleared.  */
                attrib &= ~FILE_ATTRIBUTE_READONLY;
                if (SetFileAttributes(path, attrib)) {