diff options
Diffstat (limited to 'source')
-rw-r--r--source/ui-plain.c8
1 file changed, 7 insertions, 1 deletion
diff --git a/source/ui-plain.c b/source/ui-plain.c
index 67b2044..57e4699 100644
--- a/source/ui-plain.c
+++ b/source/ui-plain.c
@@ -84,7 +84,9 @@ static void print_object(const struct object_id *oid, const char *path)
ctx.page.size = size;
cgit_print_http_headers();
html_raw(buf, size);
- free(mimetype);
+ // ctx.page.mimetype may still point into mimetype, and the headers
+ // are read again by whatever renders after this, so it stays alive
+ // for the rest of the request.
free(buf);
}
@@ -166,6 +168,10 @@ static int walk_tree(const struct object_id *oid, struct strbuf *base,
{
struct walk_tree_context *walk = context;
+ // A tree can hold two entries of one name, and only the first answers:
+ // a second response would follow the first in the same body.
+ if (walk->response != RESPONSE_NONE && walk->dir_len >= 0 && base->len == (size_t)walk->dir_len)
+ return 0;
if (walk->dir_len >= 0 && base->len == (size_t)walk->dir_len) {
if (S_ISREG(mode) || S_ISLNK(mode)) {
print_object(oid, pathname);