commit e2af0fd164e80777a70ea292bb5871329a0f8cd2 from: Stefan Sperling date: Thu Aug 08 23:13:13 2019 UTC prevent silly use-after-free with root cause in collect_commit_logmsg() commit - 003cc5a3616707763b05246329fd137ad887c3b9 commit + e2af0fd164e80777a70ea292bb5871329a0f8cd2 blob - 2d491b86591c59df3a408119c74dfa30aa5287e8 blob + 0476470fdaf1cd3d39c311d297a739bb61922472 --- got/got.c +++ got/got.c @@ -3419,8 +3419,11 @@ collect_commit_logmsg(struct got_pathlist_head *commit err = edit_logmsg(logmsg, a->editor, a->logmsg_path, initial_content); done: - unlink(a->logmsg_path); - free(a->logmsg_path); + if (err == NULL || err->code == GOT_ERR_COMMIT_MSG_EMPTY) { + unlink(a->logmsg_path); + free(a->logmsg_path); + a->logmsg_path = NULL; + } free(initial_content); free(template);