branch: fix segfault when resolving an invalid HEAD
[gitweb.git] / index-pack.c
index 61eb20e45b993a4dbd3da8954d6ca4bebb64ca13..3c768fbc631387b59bbbae3423b65b6a311a702b 100644 (file)
@@ -139,7 +139,7 @@ static const char *open_pack_file(const char *pack_name)
                if (!pack_name) {
                        static char tmpfile[PATH_MAX];
                        snprintf(tmpfile, sizeof(tmpfile),
-                                "%s/pack_XXXXXX", get_object_directory());
+                                "%s/tmp_pack_XXXXXX", get_object_directory());
                        output_fd = mkstemp(tmpfile);
                        pack_name = xstrdup(tmpfile);
                } else
@@ -358,6 +358,7 @@ static void sha1_object(const void *data, unsigned long size,
                if (size != has_size || type != has_type ||
                    memcmp(data, has_data, size) != 0)
                        die("SHA1 COLLISION FOUND WITH %s !", sha1_to_hex(sha1));
+               free(has_data);
        }
 }
 
@@ -690,7 +691,7 @@ static const char *write_index_file(const char *index_name, unsigned char *sha1)
        if (!index_name) {
                static char tmpfile[PATH_MAX];
                snprintf(tmpfile, sizeof(tmpfile),
-                        "%s/index_XXXXXX", get_object_directory());
+                        "%s/tmp_idx_XXXXXX", get_object_directory());
                fd = mkstemp(tmpfile);
                index_name = xstrdup(tmpfile);
        } else {