]> gitweb.ps.run Git - ps-cgit/commitdiff
Fix segmentation fault in hc()
authorLukas Fleischer <lfleischer@lfos.de>
Sun, 13 Dec 2015 00:27:13 +0000 (01:27 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 13 Jan 2016 16:14:01 +0000 (17:14 +0100)
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

index 48358cc04170df515e23f3a07af6111f0bab7f35..5b487342d7f09e0faca82cbdb195aa8ae076b6aa 100644 (file)
@@ -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";
 }