Commit 1e7c8b1f644e44de881a3c15b743bb558c3a71e6

Edward Thomson 2022-02-08T20:41:40

Merge pull request #6206 from libgit2/ethomson/odb_write_failures odb: check for write failures

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/src/odb.c b/src/odb.c
index 156d030..3abeae2 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -1501,10 +1501,10 @@ int git_odb_write(
 	if ((error = git_odb_open_wstream(&stream, db, len, type)) != 0)
 		return error;
 
-	stream->write(stream, data, len);
-	error = stream->finalize_write(stream, oid);
-	git_odb_stream_free(stream);
+	if ((error = stream->write(stream, data, len)) == 0)
+		error = stream->finalize_write(stream, oid);
 
+	git_odb_stream_free(stream);
 	return error;
 }