commit 217813df81cbe2ba47d4ed204298a3f204014340 from: Omar Polo via: Thomas Adam date: Fri Sep 02 15:54:01 2022 UTC gotwebd: free all allocated fields of repo_tag got_get_repo_tags needs some tweaking to how tag_commit is allocated too. ok stsp@ commit - 3179741908f46f3c1711b053ad2ab839c746a5bf commit + 217813df81cbe2ba47d4ed204298a3f204014340 blob - 0e595b8cf284b38d7e38818d5b0098211ae9e414 blob + a488ecb36b8d42ef742cd59f436be51df144be4d --- gotwebd/got_operations.c +++ gotwebd/got_operations.c @@ -573,6 +573,7 @@ got_get_repo_tags(struct request *c, int limit) struct got_tag_object *tag = NULL; struct repo_tag *rt = NULL, *trt = NULL; char *in_repo_path = NULL, *repo_path = NULL, *id_str = NULL; + char *tag_commit = NULL, *tag_commit0 = NULL; char *commit_msg = NULL, *commit_msg0 = NULL; int chk_next = 0, chk_multi = 1, commit_found = 0, c_cnt = 0; @@ -724,23 +725,30 @@ got_get_repo_tags(struct request *c, int limit) } if (commit) { - error = got_object_commit_get_logmsg(&new_repo_tag-> - tag_commit, commit); + error = got_object_commit_get_logmsg(&tag_commit0, + commit); if (error) - goto done; + goto err; got_object_commit_close(commit); commit = NULL; } else { - new_repo_tag->tag_commit = - strdup(got_object_tag_get_message(tag)); - if (new_repo_tag->tag_commit == NULL) { + tag_commit0 = strdup(got_object_tag_get_message(tag)); + if (tag_commit0 == NULL) { error = got_error_from_errno("strdup"); - goto done; + goto err; } } - while (*new_repo_tag->tag_commit == '\n') - new_repo_tag->tag_commit++; + tag_commit = tag_commit0; + while (*tag_commit == '\n') + tag_commit++; + new_repo_tag->tag_commit = strdup(tag_commit); + if (new_repo_tag->tag_commit == NULL) { + error = got_error_from_errno("strdup"); + free(tag_commit0); + goto err; + } + free(tag_commit0); if (qs->action != SUMMARY && qs->action != TAGS) { commit_msg = commit_msg0; blob - a2dac356c51f861fae48abc66f39d4227b784edb blob + 119ea8cce6faf8185d2bb72845171f54d0826016 --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -538,8 +538,10 @@ void gotweb_free_repo_tag(struct repo_tag *rt) { if (rt != NULL) { - free(rt->commit_msg); free(rt->commit_id); + free(rt->tag_name); + free(rt->tag_commit); + free(rt->commit_msg); free(rt->tagger); } free(rt);