commit 63df146dfc84e000c931f34a3ec02b115fcebb49 from: Stefan Sperling date: Mon Nov 09 16:03:35 2020 UTC fix missing unlink(tmppath) in error cases of install_blob() commit - 2ac8aa022e2ae3e7792af5fe5a66e10b241a751f commit + 63df146dfc84e000c931f34a3ec02b115fcebb49 blob - 87e1f051f27eb85cb1fd2136b9ca84911dae869e blob + cbef2cc22117046d49c0b5ce9a0fc2b5ff0da2c4 --- lib/worktree.c +++ lib/worktree.c @@ -1561,14 +1561,17 @@ install_blob(struct got_worktree *worktree, const char if (rename(tmppath, ondisk_path) != 0) { err = got_error_from_errno3("rename", tmppath, ondisk_path); - unlink(tmppath); goto done; } + free(tmppath); + tmppath = NULL; } done: if (fd != -1 && close(fd) != 0 && err == NULL) err = got_error_from_errno("close"); + if (tmppath != NULL && unlink(tmppath) == -1 && err == NULL) + err = got_error_from_errno2("unlink", tmppath); free(tmppath); return err; }