summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2017-12-23 16:38:20 +0000
committerGitHub <noreply@github.com>2017-12-23 16:38:20 +0000
commitd734466cc021f505ed5cf84e10f0a6106d8a1e75 (patch)
treec4fe81c1f539c23d7a95ac607a551cb11fec865d /src
parent9f7ad3c5d34d35a5ec2f34fa9cd8c92eff439329 (diff)
parentc3514b0b82e90e660c996e81a525d42c025503ab (diff)
downloadlibgit2-d734466cc021f505ed5cf84e10f0a6106d8a1e75.tar.gz
Merge pull request #4045 from lhchavez/fix-unpack-double-free
Fix unpack double free
Diffstat (limited to 'src')
-rw-r--r--src/indexer.c10
-rw-r--r--src/pack.c5
2 files changed, 12 insertions, 3 deletions
diff --git a/src/indexer.c b/src/indexer.c
index 7eec0d612..a5e842272 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -844,6 +844,7 @@ static int fix_thin_pack(git_indexer *idx, git_transfer_progress *stats)
static int resolve_deltas(git_indexer *idx, git_transfer_progress *stats)
{
unsigned int i;
+ int error;
struct delta_info *delta;
int progressed = 0, non_null = 0, progress_cb_result;
@@ -858,8 +859,13 @@ static int resolve_deltas(git_indexer *idx, git_transfer_progress *stats)
non_null = 1;
idx->off = delta->delta_off;
- if (git_packfile_unpack(&obj, idx->pack, &idx->off) < 0)
- continue;
+ if ((error = git_packfile_unpack(&obj, idx->pack, &idx->off)) < 0) {
+ if (error == GIT_PASSTHROUGH) {
+ /* We have not seen the base object, we'll try again later. */
+ continue;
+ }
+ return -1;
+ }
if (hash_and_save(idx, &obj, delta->delta_off) < 0)
continue;
diff --git a/src/pack.c b/src/pack.c
index b87d22d53..9ed3ec1af 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -716,8 +716,11 @@ int git_packfile_unpack(
error = packfile_unpack_compressed(&delta, p, &w_curs, &curpos, elem->size, elem->type);
git_mwindow_close(&w_curs);
- if (error < 0)
+ if (error < 0) {
+ /* We have transferred ownership of the data to the cache. */
+ obj->data = NULL;
break;
+ }
/* the current object becomes the new base, on which we apply the delta */
base = *obj;