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 9eb8bad..df74519 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)) {