ensure that gotweb's reference list heads are always initialized
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index de158a3..218a347 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -1354,13 +1354,14 @@ gw_get_repo_age(struct gw_trans *gw_trans, char *dir, char *repo_ref,
const char *refname;
char *repo_age = NULL;
+ SIMPLEQ_INIT(&refs);
+
if (repo_ref == NULL)
return NULL;
if (strncmp(repo_ref, "refs/heads/", 11) == 0)
is_head = 1;
- SIMPLEQ_INIT(&refs);
if (gw_trans->gw_conf->got_show_repo_age == false) {
if ((asprintf(&repo_age, "")) == -1)
return NULL;
@@ -1621,10 +1622,11 @@ gw_get_repo_tags(struct gw_trans *gw_trans, int limit, int tag_type)
struct buf *diffbuf = NULL;
size_t newsize;
+ SIMPLEQ_INIT(&refs);
+
error = buf_alloc(&diffbuf, 0);
if (error)
return NULL;
- SIMPLEQ_INIT(&refs);
error = got_repo_open(&repo, gw_trans->repo_path, NULL);
if (error)
@@ -2478,6 +2480,8 @@ gw_get_repo_heads(struct gw_trans *gw_trans)
struct buf *diffbuf = NULL;
size_t newsize;
+ SIMPLEQ_INIT(&refs);
+
error = buf_alloc(&diffbuf, 0);
if (error)
return NULL;
@@ -2486,7 +2490,6 @@ gw_get_repo_heads(struct gw_trans *gw_trans)
if (error)
goto done;
- SIMPLEQ_INIT(&refs);
error = got_ref_list(&refs, repo, "refs/heads", got_ref_cmp_by_name,
NULL);
if (error)