From: Filippo Negroni Date: Thu, 25 Feb 2010 10:01:31 +0000 (+0000) Subject: Fix gitmkdtemp: correct test for mktemp() return value X-Git-Tag: v1.7.0.3~21^2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/1f80c2afb0d826567a9a5a1c3ce76c28883e0e96?ds=inline;hp=--cc 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 Signed-off-by: Junio C Hamano --- 1f80c2afb0d826567a9a5a1c3ce76c28883e0e96 diff --git a/compat/mkdtemp.c b/compat/mkdtemp.c index 34d4b49818..1136119592 100644 --- a/compat/mkdtemp.c +++ b/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; }