diff options
| author | Carlos Martín Nieto <carlos@cmartin.tk> | 2012-01-19 19:09:47 +0100 |
|---|---|---|
| committer | Carlos Martín Nieto <carlos@cmartin.tk> | 2012-01-19 19:09:47 +0100 |
| commit | 20c50b9e16c19bbbf7cf38bb4bd3177596bce61b (patch) | |
| tree | d570020a769280e0ca6ab4e87d79604d945df0c1 /src/refs.c | |
| parent | 3f2bf4d659b33db9363d44f14d46154674d4049c (diff) | |
| download | libgit2-20c50b9e16c19bbbf7cf38bb4bd3177596bce61b.tar.gz | |
refs: don't leak the packref when deleting/renaming
When we remove the ref from the hashtable, we need to free the
packref.
Diffstat (limited to 'src/refs.c')
| -rw-r--r-- | src/refs.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/refs.c b/src/refs.c index 340841cc6..86e5f5dba 100644 --- a/src/refs.c +++ b/src/refs.c @@ -984,14 +984,16 @@ static int reference_delete(git_reference *ref) * We need to reload the packfile, remove the reference from the * packing list, and repack */ if (ref->flags & GIT_REF_PACKED) { + struct packref *packref; /* load the existing packfile */ if ((error = packed_load(ref->owner)) < GIT_SUCCESS) return git__rethrow(error, "Failed to delete reference"); - if (git_hashtable_remove(ref->owner->references.packfile, - ref->name) < GIT_SUCCESS) + if (git_hashtable_remove2(ref->owner->references.packfile, + ref->name, (void **) &packref) < GIT_SUCCESS) return git__throw(GIT_ENOTFOUND, "Reference not found"); + git__free (packref); error = packed_write(ref->owner); /* If the reference is loose, we can just remove the reference |
