Skip to content

Commit ded2d47

Browse files
szedergitster
authored andcommitted
mingw_utime(): handle NULL times parameter
POSIX sayeth: "If times is a null pointer, the access and modification times of the file shall be set to the current time." Let's do so. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent a146392 commit ded2d47

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compat/mingw.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,13 @@ int mingw_utime (const char *file_name, const struct utimbuf *times)
304304
goto revert_attrs;
305305
}
306306

307-
time_t_to_filetime(times->modtime, &mft);
308-
time_t_to_filetime(times->actime, &aft);
307+
if (times) {
308+
time_t_to_filetime(times->modtime, &mft);
309+
time_t_to_filetime(times->actime, &aft);
310+
} else {
311+
GetSystemTimeAsFileTime(&mft);
312+
aft = mft;
313+
}
309314
if (!SetFileTime((HANDLE)_get_osfhandle(fh), NULL, &aft, &mft)) {
310315
errno = EINVAL;
311316
rc = -1;

0 commit comments

Comments
 (0)