plug memory leaks on error in gw_tree()
diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index 624d849..be2a106 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -822,7 +822,7 @@ gw_tree(struct gw_trans *gw_trans)
error = gw_get_header(gw_trans, header, 1);
if (error)
- return error;
+ goto done;
tree_html = gw_get_repo_tree(gw_trans);
@@ -837,11 +837,15 @@ gw_tree(struct gw_trans *gw_trans)
if ((asprintf(&tree_html_disp, tree_header,
gw_gen_age_header(gw_get_time_str(header->committer_time, TM_LONG)),
gw_gen_commit_msg_header(gw_html_escape(header->commit_msg)),
- tree_html)) == -1)
- return got_error_from_errno("asprintf");
+ tree_html)) == -1) {
+ error = got_error_from_errno("asprintf");
+ goto done;
+ }
- if ((asprintf(&tree, tree_wrapper, tree_html_disp)) == -1)
- return got_error_from_errno("asprintf");
+ if (asprintf(&tree, tree_wrapper, tree_html_disp) == -1) {
+ error = got_error_from_errno("asprintf");
+ goto done;
+ }
kerr = khttp_puts(gw_trans->gw_req, tree);
if (kerr != KCGI_OK)