Skip to content

Commit e493ca5

Browse files
committed
mingw: avoid inifinite loop in rename()
We have this loop where we try to remove the read-only attribute when rename() fails and try again. If it fails again, let's not try to remove the read-only attribute and try *again*. This fixes #1299 Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 9f3a60d commit e493ca5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

compat/mingw.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2423,7 +2423,8 @@ int mingw_rename(const char *pold, const char *pnew)
24232423
return -1;
24242424
}
24252425

2426-
if ((attrs = GetFileAttributesW(wpnew)) != INVALID_FILE_ATTRIBUTES) {
2426+
if (attrs == INVALID_FILE_ATTRIBUTES &&
2427+
(attrs = GetFileAttributesW(wpnew)) != INVALID_FILE_ATTRIBUTES) {
24272428
if (attrs & FILE_ATTRIBUTE_DIRECTORY) {
24282429
DWORD attrsold = GetFileAttributesW(wpold);
24292430
if (attrsold == INVALID_FILE_ATTRIBUTES ||

0 commit comments

Comments
 (0)