Commit 1cb5a811 by XTao

Fix write_object.

parent ca55fc63
...@@ -288,6 +288,7 @@ static int write_object( ...@@ -288,6 +288,7 @@ static int write_object(
git_odb_object *obj = NULL; git_odb_object *obj = NULL;
git_otype type; git_otype type;
unsigned char hdr[10], *zbuf = NULL; unsigned char hdr[10], *zbuf = NULL;
void *delta_data = NULL;
void *data; void *data;
size_t hdr_len, zbuf_len = COMPRESS_BUFLEN, data_len; size_t hdr_len, zbuf_len = COMPRESS_BUFLEN, data_len;
ssize_t written; ssize_t written;
...@@ -295,10 +296,11 @@ static int write_object( ...@@ -295,10 +296,11 @@ static int write_object(
if (po->delta) { if (po->delta) {
if (po->delta_data) if (po->delta_data)
data = po->delta_data; delta_data = po->delta_data;
else if ((error = get_delta(&data, pb->odb, po)) < 0) else if ((error = get_delta(&delta_data, pb->odb, po)) < 0)
goto done; goto done;
data = delta_data;
data_len = po->delta_size; data_len = po->delta_size;
type = GIT_OBJ_REF_DELTA; type = GIT_OBJ_REF_DELTA;
} else { } else {
...@@ -351,7 +353,7 @@ static int write_object( ...@@ -351,7 +353,7 @@ static int write_object(
} }
if (po->delta) if (po->delta)
git__free(data); git__free(delta_data);
} }
if (po->delta_data) { if (po->delta_data) {
......
...@@ -70,7 +70,7 @@ int git_zstream_deflatebuf(git_buf *out, const void *in, size_t in_len) ...@@ -70,7 +70,7 @@ int git_zstream_deflatebuf(git_buf *out, const void *in, size_t in_len)
int error = 0; int error = 0;
if ((error = git_zstream_init(&zstream)) < 0) if ((error = git_zstream_init(&zstream)) < 0)
goto done; return error;
do { do {
if (out->asize - out->size < BUFFER_SIZE) if (out->asize - out->size < BUFFER_SIZE)
...@@ -89,7 +89,6 @@ int git_zstream_deflatebuf(git_buf *out, const void *in, size_t in_len) ...@@ -89,7 +89,6 @@ int git_zstream_deflatebuf(git_buf *out, const void *in, size_t in_len)
if (written < 0) if (written < 0)
error = written; error = written;
done:
git_zstream_free(&zstream); git_zstream_free(&zstream);
return error; return error;
} }
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