Commit Diff


commit - b3be78f9089a5962b5ae04df5f76c6d0137879d5
commit + fc9b745fd3b1a01f7e89f269600db36ad5222b3e
blob - 8dfa9ac368e4140a0ffd66fbb7761f6ef2ce5b40
blob + af1549ed25e2702af538cb0dd91835c1faaeca83
--- 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 - 62f7df1b95d5d56bd0b23c83df32e7d74f3d4b00
blob + 4030a4d264d4215f29156813c7768ef76da921b2
--- lib/fileindex.c
+++ lib/fileindex.c
@@ -1047,8 +1047,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 - 67ac8fd64b02a0f981bf9c39b34dbd03485649a2
blob + af76736e74e8d84085430ebf22b10d5375f8d887
--- lib/opentemp.c
+++ lib/opentemp.c
@@ -87,6 +87,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 - d33d541d933aef39d8511a0f97db12f13b32ac22
blob + d80d7e7c1f5c63dd86fad85a2c243e5e75c2a601
--- lib/repository.c
+++ lib/repository.c
@@ -1430,6 +1430,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;
 	}
 
@@ -2546,6 +2547,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 - ba7276ad6779e4b6a924ef8284b01c4bbdb79216
blob + b0168b3397ef9e155f6ca23c6057126006b3f1f6
--- lib/repository_admin.c
+++ lib/repository_admin.c
@@ -1525,6 +1525,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;
 	}