Commit 036be15070bf7384f9391ddd52d1fc084b1ef8da

Edward Thomson 2021-08-30T08:47:04

hashsig: close fd on error

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/hashsig.c b/src/hashsig.c
index 43310ca..6b4fb83 100644
--- a/src/hashsig.c
+++ b/src/hashsig.c
@@ -286,8 +286,10 @@ int git_hashsig_create_fromfile(
 		return fd;
 	}
 
-	if ((error = hashsig_in_progress_init(&prog, sig)) < 0)
+	if ((error = hashsig_in_progress_init(&prog, sig)) < 0) {
+		p_close(fd);
 		return error;
+	}
 
 	while (!error) {
 		if ((buflen = p_read(fd, buf, sizeof(buf))) <= 0) {