commit - 2ac8aa022e2ae3e7792af5fe5a66e10b241a751f
commit + 63df146dfc84e000c931f34a3ec02b115fcebb49
blob - 87e1f051f27eb85cb1fd2136b9ca84911dae869e
blob + cbef2cc22117046d49c0b5ce9a0fc2b5ff0da2c4
--- lib/worktree.c
+++ lib/worktree.c
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;
}