Skip to content

Commit

Permalink
mingw: avoid inifinite loop in rename()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dscho authored and Git for Windows Build Agent committed Dec 6, 2017
1 parent f962bf9 commit a7cac7c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2423,7 +2423,8 @@ int mingw_rename(const char *pold, const char *pnew)
return -1;
}

if ((attrs = GetFileAttributesW(wpnew)) != INVALID_FILE_ATTRIBUTES) {
if (attrs == INVALID_FILE_ATTRIBUTES &&
(attrs = GetFileAttributesW(wpnew)) != INVALID_FILE_ATTRIBUTES) {
if (attrs & FILE_ATTRIBUTE_DIRECTORY) {
DWORD attrsold = GetFileAttributesW(wpold);
if (attrsold == INVALID_FILE_ATTRIBUTES ||
Expand Down

0 comments on commit a7cac7c

Please sign in to comment.