Fix odb_mkstemp() on AIX
authorMike Ralphson <mike@abacus.co.uk>
Thu, 26 Feb 2009 15:31:52 +0000 (16:31 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 26 Feb 2009 16:40:27 +0000 (08:40 -0800)
The AIX mkstemp() modifies its template parameter to an empty string if
the call fails. The existing code had already recomputed the template,
but too late to be good.

See also 6ff6af62, which fixed this problem in a different spot.

Signed-off-by: Mike Ralphson <mike@abacus.co.uk>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
wrapper.c
index 231a58f1a9581b2f7e150ffe4e2f908dca3e3e61..5e9de294d51c158cbbe60a9a04c1b13765c353e8 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
@@ -208,9 +208,10 @@ int odb_mkstemp(char *template, size_t limit, const char *pattern)
                return fd;
 
        /* slow path */
-       safe_create_leading_directories(template);
+       /* some mkstemp implementations erase template on failure */
        snprintf(template, limit, "%s/%s",
                 get_object_directory(), pattern);
+       safe_create_leading_directories(template);
        return xmkstemp(template);
 }