Skip to content

Commit 1a3e007

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 ac5fa9c commit 1a3e007

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
@@ -2422,7 +2422,8 @@ int mingw_rename(const char *pold, const char *pnew)
24222422
return -1;
24232423
}
24242424

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

0 commit comments

Comments
 (0)