[PATCH] ui-shared: fix segfault when defbranch is NULL

Eric Wong normalperson at yhbt.net
Wed Jul 6 09:08:01 CEST 2016


Not sure if there's a better fix for this.  defbranch is
NULL here on my setup when a crawler hit an invalid URL,
causing strcmp to segfault.

Signed-off-by: Eric Wong <normalperson at yhbt.net>
---
 ui-shared.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui-shared.c b/ui-shared.c
index b1a6c46..e39d004 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -253,7 +253,7 @@ static char *repolink(const char *title, const char *class, const char *page,
 		}
 		delim = "&";
 	}
-	if (head && strcmp(head, ctx.repo->defbranch)) {
+	if (head && ctx.repo->defbranch && strcmp(head, ctx.repo->defbranch)) {
 		html(delim);
 		html("h=");
 		html_url_arg(head);
-- 
EW


More information about the CGit mailing list