git-send-email: add a new sendemail.to configuration variable
[gitweb.git] / builtin-archive.c
index 843a9e37bbb5b7274e928499d3b7935399216e65..6f29c2f40a01b3c60eaa9ecfa1ca4d63fe90c8eb 100644 (file)
@@ -89,7 +89,7 @@ static void format_subst(const struct commit *commit,
        struct strbuf fmt;
 
        if (src == buf->buf)
-               to_free = strbuf_detach(buf);
+               to_free = strbuf_detach(buf, NULL);
        strbuf_init(&fmt, 0);
        for (;;) {
                const char *b, *c;
@@ -148,13 +148,14 @@ void *sha1_file_to_archive(const char *path, const unsigned char *sha1,
        buffer = read_sha1_file(sha1, type, sizep);
        if (buffer && S_ISREG(mode)) {
                struct strbuf buf;
+               size_t size = 0;
 
                strbuf_init(&buf, 0);
                strbuf_attach(&buf, buffer, *sizep, *sizep + 1);
                convert_to_working_tree(path, buf.buf, buf.len, &buf);
                convert_to_archive(path, buf.buf, buf.len, &buf, commit);
-               *sizep = buf.len;
-               buffer = buf.buf;
+               buffer = strbuf_detach(&buf, &size);
+               *sizep = size;
        }
 
        return buffer;