Skip to content

Commit e2ddb4f

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 9cfeb14 commit e2ddb4f

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
@@ -2428,7 +2428,8 @@ int mingw_rename(const char *pold, const char *pnew)
24282428
return -1;
24292429
}
24302430

2431-
if ((attrs = GetFileAttributesW(wpnew)) != INVALID_FILE_ATTRIBUTES) {
2431+
if (attrs == INVALID_FILE_ATTRIBUTES &&
2432+
(attrs = GetFileAttributesW(wpnew)) != INVALID_FILE_ATTRIBUTES) {
24322433
if (attrs & FILE_ATTRIBUTE_DIRECTORY) {
24332434
DWORD attrsold = GetFileAttributesW(wpold);
24342435
if (attrsold == INVALID_FILE_ATTRIBUTES ||

0 commit comments

Comments
 (0)