Commit b169cd522e796de3d47d5725d73ab5a0ed88ccf6

Patrick Steinhardt 2020-02-07T12:13:42

pack-objects: check return code of `git_zstream_set_input` While `git_zstream_set_input` cannot fail right now, it might change in the future if we ever decide to have it check its parameters more vigorously. Let's thus check whether its return code signals an error.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/pack-objects.c b/src/pack-objects.c
index bdd5171..49b4e47 100644
--- a/src/pack-objects.c
+++ b/src/pack-objects.c
@@ -374,7 +374,9 @@ static int write_object(
 		GIT_ERROR_CHECK_ALLOC(zbuf);
 
 		git_zstream_reset(&pb->zstream);
-		git_zstream_set_input(&pb->zstream, data, data_len);
+
+		if ((error = git_zstream_set_input(&pb->zstream, data, data_len)) < 0)
+			goto done;
 
 		while (!git_zstream_done(&pb->zstream)) {
 			if ((error = git_zstream_get_output(zbuf, &zbuf_len, &pb->zstream)) < 0 ||