Commit c19a3c7a23a972e25e013cff300343323e65a55f

Edward Thomson 2022-02-07T11:22:04

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;
 }