From 28ebd986920812c7f91f30a3f3783d1ab3c951d0 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Mon, 13 Jan 2014 14:35:12 -0600 Subject: [PATCH] win32_delete_file_wrapper(): Check for INVALID_FILE_ATTRIBUTES --- src/win32_apply.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/win32_apply.c b/src/win32_apply.c index 9eb8bad0..df74519d 100644 --- a/src/win32_apply.c +++ b/src/win32_apply.c @@ -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)) { -- 2.43.0