mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-07 16:22:40 +00:00
refs: don't leak the packref when deleting/renaming
When we remove the ref from the hashtable, we need to free the packref.
This commit is contained in:
parent
3f2bf4d659
commit
20c50b9e16
@ -984,14 +984,16 @@ static int reference_delete(git_reference *ref)
|
|||||||
* We need to reload the packfile, remove the reference from the
|
* We need to reload the packfile, remove the reference from the
|
||||||
* packing list, and repack */
|
* packing list, and repack */
|
||||||
if (ref->flags & GIT_REF_PACKED) {
|
if (ref->flags & GIT_REF_PACKED) {
|
||||||
|
struct packref *packref;
|
||||||
/* load the existing packfile */
|
/* load the existing packfile */
|
||||||
if ((error = packed_load(ref->owner)) < GIT_SUCCESS)
|
if ((error = packed_load(ref->owner)) < GIT_SUCCESS)
|
||||||
return git__rethrow(error, "Failed to delete reference");
|
return git__rethrow(error, "Failed to delete reference");
|
||||||
|
|
||||||
if (git_hashtable_remove(ref->owner->references.packfile,
|
if (git_hashtable_remove2(ref->owner->references.packfile,
|
||||||
ref->name) < GIT_SUCCESS)
|
ref->name, (void **) &packref) < GIT_SUCCESS)
|
||||||
return git__throw(GIT_ENOTFOUND, "Reference not found");
|
return git__throw(GIT_ENOTFOUND, "Reference not found");
|
||||||
|
|
||||||
|
git__free (packref);
|
||||||
error = packed_write(ref->owner);
|
error = packed_write(ref->owner);
|
||||||
|
|
||||||
/* If the reference is loose, we can just remove the reference
|
/* If the reference is loose, we can just remove the reference
|
||||||
|
Loading…
Reference in New Issue
Block a user