Skip to content

Commit

Permalink
Fix gitmkdtemp: correct test for mktemp() return value
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Filippo Negroni authored and gitster committed Feb 25, 2010
1 parent 0606c36 commit 1f80c2a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compat/mkdtemp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

char *gitmkdtemp(char *template)
{
if (!mktemp(template) || mkdir(template, 0700))
if (!*mktemp(template) || mkdir(template, 0700))
return NULL;
return template;
}

0 comments on commit 1f80c2a

Please sign in to comment.