From: Stefan Sperling Subject: Re: Remove /tmp/got-importmsg on empty import commit message To: Johannes Thyssen Tishman , gameoftrees@openbsd.org Date: Sat, 26 Apr 2025 21:17:32 +0200 On Sat, Apr 26, 2025 at 06:14:52PM +0000, Johannes Thyssen Tishman wrote: > While testing the symlink behavior from my previous email I noticed some > leftover /tmp/got-importmsg files that were not cleaned after incomplete > imports with empty commit messages. From what I understand, this happens > because the logmsg_path pointer is freed before unlink() can be called > even when the pointer is already being freed in cmd_import(). Is this > correct? The diff below seems to fix this for me. Regression tests are > all passing. A general principle I like to follow is that on error, the function which creates resources for its caller will not return those resources and clean them up itself. So in this case I would prefer to duplicate the unlink() call inside collect_import_msg() if an error occurred, because that's where the bug is.