Skip to content

Commit 62fcbf0

Browse files
dschoGit for Windows Build Agent
authored andcommitted
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 f7dfa95 commit 62fcbf0

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

2396-
if ((attrs = GetFileAttributesW(wpnew)) != INVALID_FILE_ATTRIBUTES) {
2396+
if (attrs == INVALID_FILE_ATTRIBUTES &&
2397+
(attrs = GetFileAttributesW(wpnew)) != INVALID_FILE_ATTRIBUTES) {
23972398
if (attrs & FILE_ATTRIBUTE_DIRECTORY) {
23982399
DWORD attrsold = GetFileAttributesW(wpold);
23992400
if (attrsold == INVALID_FILE_ATTRIBUTES ||

0 commit comments

Comments
 (0)