]> rtime.felk.cvut.cz Git - git.git/commitdiff
Fix gitmkdtemp: correct test for mktemp() return value
authorFilippo Negroni <fnegroni@flexerasoftware.com>
Thu, 25 Feb 2010 10:01:31 +0000 (10:01 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 25 Feb 2010 20:08:22 +0000 (12:08 -0800)
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>
compat/mkdtemp.c

index 34d4b49818b0896b9db19b2b1387f142cbbbd42b..11361195925c674423309d40f343c88f58b7bc1e 100644 (file)
@@ -2,7 +2,7 @@
 
 char *gitmkdtemp(char *template)
 {
-       if (!mktemp(template) || mkdir(template, 0700))
+       if (!*mktemp(template) || mkdir(template, 0700))
                return NULL;
        return template;
 }