summaryrefslogtreecommitdiff
path: root/src/pack-objects.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pack-objects.c')
-rw-r--r--src/pack-objects.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/pack-objects.c b/src/pack-objects.c
index 7ce1b6cb3..335944c0c 100644
--- a/src/pack-objects.c
+++ b/src/pack-objects.c
@@ -332,8 +332,10 @@ static int write_object(git_buf *buf, git_packbuilder *pb, git_pobject *po)
git_hash_update(&pb->ctx, data, size) < 0)
goto on_error;
- if (po->delta_data)
+ if (po->delta_data) {
git__free(po->delta_data);
+ po->delta_data = NULL;
+ }
git_odb_object_free(obj);
git_buf_free(&zbuf);
@@ -612,6 +614,15 @@ static int write_pack(git_packbuilder *pb,
error = cb(entry_oid.id, GIT_OID_RAWSZ, data);
done:
+ /* if callback cancelled writing, we must still free delta_data */
+ for ( ; i < pb->nr_objects; ++i) {
+ po = write_order[i];
+ if (po->delta_data) {
+ git__free(po->delta_data);
+ po->delta_data = NULL;
+ }
+ }
+
git__free(write_order);
git_buf_free(&buf);
return error;