Browse files

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 <fnegroni@flexerasoftware.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information...
1 parent 0606c36 commit 1f80c2afb0d826567a9a5a1c3ce76c28883e0e96 Filippo Negroni committed with gitster Feb 25, 2010
Showing with 1 addition and 1 deletion.
  1. +1 −1 compat/mkdtemp.c
View
2 compat/mkdtemp.c
@@ -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.