Commit 1e9b7a09 by Vicent Martí

Merge pull request #144 from nordsturm/fix_fakewstream

Fix fake wstream write
parents 7107b599 1d1735fe
...@@ -64,7 +64,10 @@ int git_blob_create_frombuffer(git_oid *oid, git_repository *repo, const void *b ...@@ -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) if ((error = git_odb_open_wstream(&stream, repo->db, len, GIT_OBJ_BLOB)) < GIT_SUCCESS)
return git__rethrow(error, "Failed to create blob"); return git__rethrow(error, "Failed to create blob");
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); error = stream->finalize_write(oid, stream);
stream->free(stream); stream->free(stream);
......
...@@ -170,7 +170,7 @@ static int fake_wstream__write(git_odb_stream *_stream, const char *data, size_t ...@@ -170,7 +170,7 @@ static int fake_wstream__write(git_odb_stream *_stream, const char *data, size_t
{ {
fake_wstream *stream = (fake_wstream *)_stream; fake_wstream *stream = (fake_wstream *)_stream;
if (stream->written + len >= stream->size) if (stream->written + len > stream->size)
return GIT_ENOMEM; return GIT_ENOMEM;
memcpy(stream->buffer + stream->written, data, len); memcpy(stream->buffer + stream->written, data, len);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment