From 8d946079c5f51ce934ff5edf6333962c6061d8a5 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 1 Feb 2010 17:55:37 +0100 Subject: ui-shared.c: fix segfault when repo is empty PATH_INFO="/$REPONAME/commit/?id=1" QUERY_STRING="id=1" ./cgit.cgi triggers segfault when the repository is empty and therefore ctx.qry.head is unset Signed-off-by: Florian Pritz Signed-off-by: Lars Hjemli --- ui-shared.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui-shared.c b/ui-shared.c index 4049a2b..8a7cc32 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -246,7 +246,7 @@ static void reporevlink(char *page, char *name, char *title, char *class, char *delim; delim = repolink(title, class, page, head, path); - if (rev && strcmp(rev, ctx.qry.head)) { + if (rev && ctx.qry.head != NULL && strcmp(rev, ctx.qry.head)) { html(delim); html("id="); html_url_arg(rev); @@ -346,7 +346,7 @@ void cgit_diff_link(char *name, char *title, char *class, char *head, char *delim; delim = repolink(title, class, "diff", head, path); - if (new_rev && strcmp(new_rev, ctx.qry.head)) { + if (new_rev && ctx.qry.head != NULL && strcmp(new_rev, ctx.qry.head)) { html(delim); html("id="); html_url_arg(new_rev); -- cgit v1.2.3-59-g8ed1b From 9bd3a7b1ea6c5863d7cba1b5352ce707f5d129a0 Mon Sep 17 00:00:00 2001 From: Daniel Milde Date: Sun, 21 Feb 2010 14:38:59 +0100 Subject: Clear the whole context Signed-off-by: Lars Hjemli --- cgit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cgit.c b/cgit.c index 6bb712d..6c7e811 100644 --- a/cgit.c +++ b/cgit.c @@ -248,7 +248,7 @@ char *xstrdupn(const char *str) static void prepare_context(struct cgit_context *ctx) { - memset(ctx, 0, sizeof(ctx)); + memset(ctx, 0, sizeof(*ctx)); ctx->cfg.agefile = "info/web/last-modified"; ctx->cfg.nocache = 0; ctx->cfg.cache_size = 0; -- cgit v1.2.3-59-g8ed1b