cgit

commit 8d946079c5f51ce934ff5edf6333962c6061d8a5

Author: Florian Pritz <bluewind@xssn.at>

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 <bluewind@xssn.at>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>

 ui-shared.c | 4 ++--


diff --git a/ui-shared.c b/ui-shared.c
index 4049a2b6811d42d44f5eacfaefbda05244063e1b..8a7cc323363cc39837092609fee076300be95f60 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -246,7 +246,7 @@ {
 	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 @@ {
 	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);