Skip to content

Commit a2cb86c

Browse files
daleworleygitster
authored andcommitted
git_mkstemps: correctly test return value of open()
open() returns -1 on failure, and indeed 0 is a possible success value if the user closed stdin in our process. Fix the test. Signed-off-by: Thomas Rast <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 62e91ef commit a2cb86c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

wrapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ int git_mkstemps_mode(char *pattern, int suffix_len, int mode)
322322
template[5] = letters[v % num_letters]; v /= num_letters;
323323

324324
fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, mode);
325-
if (fd > 0)
325+
if (fd >= 0)
326326
return fd;
327327
/*
328328
* Fatal error (EPERM, ENOSPC etc).

0 commit comments

Comments
 (0)