commit - 783ec1071f0be07fd6586dacb6e66e53246995b3
commit + 51d4a92dec90f3898fd2ab9d7230625c79dfb861
blob - 0707fdc1d6e5dbd06a7bbfc49cfff5b3f6c58ea6
blob + 60c969d78a824024f807fb3dca372f9024a3c4ce
--- gotweb/gotweb.c
+++ gotweb/gotweb.c
struct gw_header *);
static const struct got_error *gw_get_repo_tags(char **, struct gw_trans *,
struct gw_header *, int, int);
-static char *gw_get_repo_heads(struct gw_trans *);
+static const struct got_error *gw_get_repo_heads(char **, struct gw_trans *);
static const struct got_error *gw_get_clone_url(char **, struct gw_trans *, char *);
static char *gw_get_got_link(struct gw_trans *);
static char *gw_get_site_link(struct gw_trans *);
}
/* heads */
- heads = gw_get_repo_heads(gw_trans);
+ error = gw_get_repo_heads(&heads, gw_trans);
+ if (error)
+ goto done;
if (heads != NULL && strcmp(heads, "") != 0) {
kerr = khtml_attr(gw_trans->gw_html_req, KELEM_DIV,
KATTR_ID, "summary_heads_title_wrapper", KATTR__MAX);
return error;
}
-static char *
-gw_get_repo_heads(struct gw_trans *gw_trans)
+static const struct got_error *
+gw_get_repo_heads(char **head_html, struct gw_trans *gw_trans)
{
const struct got_error *error = NULL;
struct got_repository *repo = NULL;
struct got_reflist_head refs;
struct got_reflist_entry *re;
- char *heads, *head_row = NULL, *head_navs_disp = NULL, *age = NULL;
+ char *head_row = NULL, *head_navs_disp = NULL, *age = NULL;
struct buf *diffbuf = NULL;
size_t newsize;
+ *head_html = NULL;
+
SIMPLEQ_INIT(&refs);
error = buf_alloc(&diffbuf, 0);
if (buf_len(diffbuf) > 0) {
error = buf_putc(diffbuf, '\0');
- heads = strdup(buf_get(diffbuf));
+ *head_html = strdup(buf_get(diffbuf));
+ if (*head_html == NULL)
+ error = got_error_from_errno("strdup");
}
done:
buf_free(diffbuf);
got_ref_list_free(&refs);
if (repo)
got_repo_close(repo);
- if (error)
- return NULL;
- else
- return heads;
+ return error;
}
static char *