cgit

commit da1b89710f5eb25297a66613ff3130b2a31cb86a

Author: Lukas Fleischer <lfleischer@lfos.de>

Fix segmentation fault in hc()

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@lfos.de>

 ui-shared.c | 3 +++


diff --git a/ui-shared.c b/ui-shared.c
index 48358cc04170df515e23f3a07af6111f0bab7f35..5b487342d7f09e0faca82cbdb195aa8ae076b6aa 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -889,6 +889,9 @@ }
 
 static const char *hc(const char *page)
 {
+	if (!ctx.qry.page)
+		return NULL;
+
 	return strcmp(ctx.qry.page, page) ? NULL : "active";
 }