From b710d444abed831b69a8805d2a7686b1b6543fb1 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 13:15:38 -0700 Subject: Stop leaking the short hash of an object link --- source/ui-shared.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/source/ui-shared.c b/source/ui-shared.c index 9ad398f..2760f64 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -1076,16 +1076,13 @@ void cgit_stats_link(const char *name, const char *title, const char *class, void cgit_object_link(struct object *obj, int full) { const char *page; - char *shortrev, *fullrev, *name; + char *fullrev, *name; fullrev = oid_to_hex(&obj->oid); - if (full) { + if (full) name = cgit_fmt("%s %s", type_name(obj->type), fullrev); - } else { - shortrev = xstrdup(fullrev); - shortrev[SHORT_HASH_LEN] = '\0'; - name = cgit_fmt("%s %s...", type_name(obj->type), shortrev); - } + else + name = cgit_fmt("%s %.*s...", type_name(obj->type), SHORT_HASH_LEN, fullrev); if (obj->type == OBJ_COMMIT) { cgit_commit_link(name, NULL, NULL, ctx.qry.head, fullrev, NULL); return; -- cgit