about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJohn Keeping2011-11-24 11:54:47 +0000
committerLars Hjemli2012-01-03 21:00:30 +0000
commit94b7c76e531315b245f79a9e2dfd0655e6e45fee (patch)
tree3fa4bac9eb6a30ede630fbbdc11877dbd85c6e0e
parentMakefile: fetch git tarballs from http://hjemli.net/git/git/ (diff)
downloadcgit-94b7c76e531315b245f79a9e2dfd0655e6e45fee.tar.gz
cgit-94b7c76e531315b245f79a9e2dfd0655e6e45fee.zip
Fix segmentation fault in empty repository
When a repository is empty, the ATOM feed link is written in the header,
but this involves formatting ctx->qry.head which is NULL in this case.
With glibc, vsnprintf formats "%s" with a NULL input as "(null)" but on
Solaris this results in a segmentation fault.  Since we don't have a
meaningful head for the atom feed in an empty repository, it's simplest
not to write out the link element at all.

Signed-off-by: John Keeping <john@metanate.com>
-rw-r--r--ui-shared.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ui-shared.c b/ui-shared.c index 85c2096..3e9282f 100644 --- a/ui-shared.c +++ b/ui-shared.c
@@ -619,7 +619,7 @@ void cgit_print_docstart(struct cgit_context *ctx)
619 html_attr(ctx->cfg.favicon); 619 html_attr(ctx->cfg.favicon);
620 html("'/>\n"); 620 html("'/>\n");
621 } 621 }
622 if (host && ctx->repo) { 622 if (host && ctx->repo && ctx->qry.head) {
623 html("<link rel='alternate' title='Atom feed' href='"); 623 html("<link rel='alternate' title='Atom feed' href='");
624 html(cgit_httpscheme()); 624 html(cgit_httpscheme());
625 html_attr(cgit_hosturl()); 625 html_attr(cgit_hosturl());