Merge pull request #6206 from libgit2/ethomson/odb_write_failures odb: check for write failures
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;
}