Skip to content

Commit d9430ee

Browse files
committed
mingw: avoid infinite 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 a54f044 commit d9430ee

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
@@ -2391,7 +2391,8 @@ int mingw_rename(const char *pold, const char *pnew)
23912391
return -1;
23922392
}
23932393

2394-
if ((attrs = GetFileAttributesW(wpnew)) != INVALID_FILE_ATTRIBUTES) {
2394+
if (attrs == INVALID_FILE_ATTRIBUTES &&
2395+
(attrs = GetFileAttributesW(wpnew)) != INVALID_FILE_ATTRIBUTES) {
23952396
if (attrs & FILE_ATTRIBUTE_DIRECTORY) {
23962397
DWORD attrsold = GetFileAttributesW(wpold);
23972398
if (attrsold == INVALID_FILE_ATTRIBUTES ||

0 commit comments

Comments
 (0)