Commit Diff


commit - 098056c9af1a2a51aeabb65765cdce5ffc5f1021
commit + 815470d403e59ff4438e21bc01b4c4b4aac3b579
blob - 6ed6c8dc27efd3a85d31e6885b8eefb2e80b06e5
blob + 3bea8ee5472c8db2fa99bd3af427db014e7a0df1
--- gotd/repo_read.c
+++ gotd/repo_read.c
@@ -664,6 +664,10 @@ send_packfile(struct imsg *imsg, struct gotd_imsgev *i
 	    PROC_REPO_READ, -1, &idone, sizeof(idone)) == -1)
 		err = got_error_from_errno("imsg compose PACKFILE_DONE");
 done:
+	if (client->delta_cache_fd != -1 &&
+	    close(client->delta_cache_fd) == -1 && err == NULL)
+		err = got_error_from_errno("close");
+	client->delta_cache_fd = -1;
 	if (delta_cache != NULL && fclose(delta_cache) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 	imsg_clear(&ibuf);
blob - a27a238bed16b32c894a7550a46b26e903460d93
blob + 088fe0094a513567852e64b70f4a6581b91796e1
--- lib/fileindex.c
+++ lib/fileindex.c
@@ -1044,8 +1044,13 @@ walk_dir(struct got_pathlist_entry **next, struct got_
 		}
 
 		subdir = fdopendir(subdirfd);
-		if (subdir == NULL)
-			return got_error_from_errno2("fdopendir", path);
+		if (subdir == NULL) {
+			err = got_error_from_errno2("fdopendir", path);
+			close(subdirfd);
+			free(subpath);
+			free(subdirpath);
+			return err;
+		}
 		subdirfd = -1;
 		err = read_dirlist(&subdirlist, subdir, subdirpath);
 		if (err) {
blob - 214927a93b56207296b933bdf3a8b1b2b8e517ca
blob + 0794b2e04314c60cac1d027dfcaacf239cf877c6
--- lib/opentemp.c
+++ lib/opentemp.c
@@ -88,6 +88,7 @@ got_opentemp_named(char **path, FILE **outfile, const 
 	*outfile = fdopen(fd, "w+");
 	if (*outfile == NULL) {
 		err = got_error_from_errno2("fdopen", *path);
+		close(fd);
 		free(*path);
 		*path = NULL;
 	}
blob - 9e58244dfa2381523d54c703cd1e1059b769fe3f
blob + 577836766672831b4f5c95f77ce65ef38fa65ee0
--- lib/repository.c
+++ lib/repository.c
@@ -1426,6 +1426,7 @@ got_repo_list_packidx(struct got_pathlist_head *packid
 	packdir = fdopendir(packdir_fd);
 	if (packdir == NULL) {
 		err = got_error_from_errno("fdopendir");
+		close(packdir_fd);
 		goto done;
 	}
 
@@ -2543,6 +2544,7 @@ got_repo_get_packfile_info(int *npackfiles, int *nobje
 	packdir = fdopendir(packdir_fd);
 	if (packdir == NULL) {
 		err = got_error_from_errno("fdopendir");
+		close(packdir_fd);
 		goto done;
 	}
 
blob - eaa48a5b03869256d513b30857a279f6d21d6ad3
blob + 1f4448f8716f1f1e4ecc4e33a59534c9fdf7ad98
--- lib/repository_admin.c
+++ lib/repository_admin.c
@@ -1522,6 +1522,7 @@ got_repo_remove_lonely_packidx(struct got_repository *
 	packdir = fdopendir(packdir_fd);
 	if (packdir == NULL) {
 		err = got_error_from_errno("fdopendir");
+		close(packdir_fd);
 		goto done;
 	}