Skip to content

Commit 1f80c2a

Browse files
Filippo Negronigitster
authored andcommitted
Fix gitmkdtemp: correct test for mktemp() return value
In gitmkdtemp, the return value of mktemp is not tested correctly. mktemp() always returns its 'template' argument, even upon failure. An error is signalled by making the template an empty string. Signed-off-by: Filippo Negroni <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0606c36 commit 1f80c2a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compat/mkdtemp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
char *gitmkdtemp(char *template)
44
{
5-
if (!mktemp(template) || mkdir(template, 0700))
5+
if (!*mktemp(template) || mkdir(template, 0700))
66
return NULL;
77
return template;
88
}

0 commit comments

Comments
 (0)