commit 59f86c768fa5ca12721c72172aa968062fceafea from: Stefan Sperling date: Fri Sep 11 17:26:40 2020 UTC plug memory leaks in error paths while collecting log messages commit - 97972933210f224479bf2e8f44c4cb88a2dec393 commit + 59f86c768fa5ca12721c72172aa968062fceafea blob - 47edd6740e291c0126563b4b3e27ef5aed14614a blob + f09b05108b42ad7589c03f7312b0a9924b7fe0d8 --- got/got.c +++ got/got.c @@ -512,6 +512,10 @@ done: if (fd != -1 && close(fd) == -1 && err == NULL) err = got_error_from_errno2("close", *logmsg_path); free(initial_content); + if (err) { + free(*logmsg_path); + *logmsg_path = NULL; + } return err; } @@ -5727,12 +5731,11 @@ done: err = got_error_from_errno2("close", *tagmsg_path); /* Editor is done; we can now apply unveil(2) */ - if (err == NULL) { + if (err == NULL) err = apply_unveil(repo_path, 0, NULL); - if (err) { - free(*tagmsg); - *tagmsg = NULL; - } + if (err) { + free(*tagmsg); + *tagmsg = NULL; } return err; } @@ -6607,12 +6610,11 @@ done: err = got_error_from_errno2("close", a->logmsg_path); /* Editor is done; we can now apply unveil(2) */ - if (err == NULL) { + if (err == NULL) err = apply_unveil(a->repo_path, 0, a->worktree_path); - if (err) { - free(*logmsg); - *logmsg = NULL; - } + if (err) { + free(*logmsg); + *logmsg = NULL; } return err; }