Commit Diff


commit - 1338848fa6ee90aee6431e1085445fa4953b036a
commit + 43ff8261e1c6fdb609986add011ed0313f6eabe6
blob - b5e37a2ef18787b5f1bd0f78f8bcc6595e437bc2
blob + 9eb8aa6b3eb9f5b01200496dc831e990f16f4a3e
--- lib/worktree.c
+++ lib/worktree.c
@@ -1210,7 +1210,7 @@ get_file_status(unsigned char *status, struct stat *sb
 done:
 	if (blob)
 		got_object_blob_close(blob);
-	if (f)
+	if (f != NULL && fclose(f) == EOF && err == NULL)
 		fclose(f);
 	if (fd != -1 && close(fd) == -1 && err == NULL)
 		err = got_error_from_errno2("close", abspath);