commit b64b1f953a75e1e6639a1fd16a0dc4ce19f4ae78 from: Stefan Sperling date: Mon Jan 06 13:10:00 2020 UTC plug a memory leak; parsed tree entries were not freed commit - fa7a529ed4c1497b79f04fcd0484304e69b28873 commit + b64b1f953a75e1e6639a1fd16a0dc4ce19f4ae78 blob - 08660f26facc1d87231e58e9db7d096e06d4897a blob + 9a940e36521468e7c66573584ffde982297779af --- lib/got_lib_object_parse.h +++ lib/got_lib_object_parse.h @@ -34,6 +34,7 @@ struct got_parsed_tree_entry { }; const struct got_error *got_object_parse_tree(struct got_pathlist_head *, int *, uint8_t *, size_t); +void got_object_tree_entries_free(struct got_pathlist_head *); const struct got_error *got_object_parse_tag(struct got_tag_object **, uint8_t *, size_t); blob - fe0992ae79d11ceba995c59a3d8895c0dd55ea53 blob + 3449f6bd20453520e2864886ff300184b537f3df --- lib/object_parse.c +++ lib/object_parse.c @@ -719,10 +719,22 @@ got_object_parse_tree(struct got_pathlist_head *entrie } done: if (err) { - got_pathlist_free(entries); + got_object_tree_entries_free(entries); *nentries = 0; } return err; +} + +void +got_object_tree_entries_free(struct got_pathlist_head *entries) +{ + struct got_pathlist_entry *pe; + + TAILQ_FOREACH(pe, entries, entry) { + struct got_parsed_tree_entry *pte = pe->data; + free(pte); + } + got_pathlist_free(entries); } void blob - f130a21a81e49ebf7483be526ba5b6ea351b3c91 blob + 9e71e26859bb960f740d7b367d0e7d1a51095c76 --- libexec/got-read-pack/got-read-pack.c +++ libexec/got-read-pack/got-read-pack.c @@ -203,7 +203,7 @@ tree_request(struct imsg *imsg, struct imsgbuf *ibuf, err = got_privsep_send_tree(ibuf, &entries, nentries); done: - got_pathlist_free(&entries); + got_object_tree_entries_free(&entries); free(buf); got_object_close(obj); if (err) { blob - 3e24db2fa40abdd99961db56310f1a4814f29c71 blob + 36075902cd0313335fba82e43693eaed162f57af --- libexec/got-read-tree/got-read-tree.c +++ libexec/got-read-tree/got-read-tree.c @@ -143,7 +143,7 @@ main(int argc, char *argv[]) err = got_privsep_send_tree(&ibuf, &entries, nentries); done: - got_pathlist_free(&entries); + got_object_tree_entries_free(&entries); free(buf); if (f) { if (fclose(f) != 0 && err == NULL)