* [PATCH] ui-shared: fix segfault when defbranch is NULL
@ 2016-07-06 7:08 normalperson
2016-07-06 8:44 ` john
2016-07-06 9:29 ` Jason
0 siblings, 2 replies; 3+ messages in thread
From: normalperson @ 2016-07-06 7:08 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] ui-shared: fix segfault when defbranch is NULL
2016-07-06 7:08 [PATCH] ui-shared: fix segfault when defbranch is NULL normalperson
@ 2016-07-06 8:44 ` john
2016-07-06 9:29 ` Jason
1 sibling, 0 replies; 3+ messages in thread
From: john @ 2016-07-06 8:44 UTC (permalink / raw)
On Wed, Jul 06, 2016 at 07:08:01AM +0000, Eric Wong wrote:
> 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)) {
This looks sensible to me. We guarantee that defbranch is non-null in
prepare_repo_cmd() but this function can be called from the repository
list via (at least) cgit_summary_link(), so it may be null here.
All of the other use sites are already protected by null checks except
the one reached via find_default_branch() but that is called immediately
after we have made sure that defbranch is non-null.
> html(delim);
> html("h=");
> html_url_arg(head);
> --
> EW
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] ui-shared: fix segfault when defbranch is NULL
2016-07-06 7:08 [PATCH] ui-shared: fix segfault when defbranch is NULL normalperson
2016-07-06 8:44 ` john
@ 2016-07-06 9:29 ` Jason
1 sibling, 0 replies; 3+ messages in thread
From: Jason @ 2016-07-06 9:29 UTC (permalink / raw)
Hi Eric,
Looks good to me. Merged.
Thanks,
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-07-06 9:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-06 7:08 [PATCH] ui-shared: fix segfault when defbranch is NULL normalperson
2016-07-06 8:44 ` john
2016-07-06 9:29 ` Jason
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).