commit 58379602a09f7b61fab5d50b3c69f713a99af8d1 from: Stefan Sperling date: Mon Apr 02 09:40:53 2018 UTC clean up commit list in print_commits() after any error in the loop commit - 6c6d3ed32e74fe87db0f4bc0fbf16c620dc5301b commit + 58379602a09f7b61fab5d50b3c69f713a99af8d1 blob - 598997cc014c7b11b38dc879cb7bf84ec7445a0f blob + bbfab873890ceb2606f14caf474860a375bc8575 --- got/got.c +++ got/got.c @@ -367,16 +367,8 @@ print_commits(struct got_object *root_obj, struct got_ entry = TAILQ_FIRST(&commits); err = print_commit(entry->commit, entry->id, repo, show_patch); - if (err) { - while (!TAILQ_EMPTY(&commits)) { - entry = TAILQ_FIRST(&commits); - TAILQ_REMOVE(&commits, entry, entry); - got_object_commit_close(entry->commit); - free(entry->id); - free(entry); - } + if (err) break; - } if (limit && --limit == 0) break; @@ -419,6 +411,16 @@ print_commits(struct got_object *root_obj, struct got_ got_object_commit_close(entry->commit); free(entry->id); free(entry); + } + + if (err) { + while (!TAILQ_EMPTY(&commits)) { + entry = TAILQ_FIRST(&commits); + TAILQ_REMOVE(&commits, entry, entry); + got_object_commit_close(entry->commit); + free(entry->id); + free(entry); + } } return err;