Commit 1d1735fe03a53482c6545252bd567555d5d9b487

Sergey Nikishin 2011-04-24T18:33:50

Add error processing in git_blob_create_frombuffer()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/blob.c b/src/blob.c
index 5e3c22f..69a0b95 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -64,7 +64,10 @@ int git_blob_create_frombuffer(git_oid *oid, git_repository *repo, const void *b
 	if ((error = git_odb_open_wstream(&stream, repo->db, len, GIT_OBJ_BLOB)) < GIT_SUCCESS)
 		return error;
 
-	stream->write(stream, buffer, len);
+	if ((error = stream->write(stream, buffer, len)) < GIT_SUCCESS) {
+		stream->free(stream);
+		return error;
+	}
 
 	error = stream->finalize_write(oid, stream);
 	stream->free(stream);