[PATCH] Fix segmentation fault in hc()

Lukas Fleischer lfleischer at lfos.de
Sun Dec 13 01:27:13 CET 2015


The ctx.qry.page variable might be unset at this point, e.g. when an
invalid command is passed and cgit_print_pageheader() is called to show
an error message.

Signed-off-by: Lukas Fleischer <lfleischer at lfos.de>
---
 ui-shared.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ui-shared.c b/ui-shared.c
index c04f380..6b78b91 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -889,6 +889,9 @@ void cgit_add_hidden_formfields(int incl_head, int incl_search,
 
 static const char *hc(const char *page)
 {
+	if (!ctx.qry.page)
+		return NULL;
+
 	return strcmp(ctx.qry.page, page) ? NULL : "active";
 }
 
-- 
2.6.4



More information about the CGit mailing list