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>
Filippo Negroni committed
Feb 25, 2010 at 10:01 UTC
1f80c2afb0d826567a9a5a1c3ce76c28883e0e96
1 file changed
+1
-1
compat/mkdtemp.c
+1
-1
@@ -2,7 +2,7 @@
2
3
char *gitmkdtemp(char *template)
4
{
5
- if (!mktemp(template) || mkdir(template, 0700))
5
+ if (!*mktemp(template) || mkdir(template, 0700))
6
return NULL;
7
return template;
8
}