diff options
| author | Patrick Steinhardt <ps@pks.im> | 2024-09-05 12:09:15 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-09-05 08:49:12 -0700 |
| commit | 14c0ea0f6f7a0898214d8fa822a2392ef3a00f53 (patch) | |
| tree | 2169fea90a757a594ae9754b4eddfe85a1bd1ae0 /shallow.c | |
| parent | 0d1d22f5a385d05bde40303c17483db2eec499b3 (diff) | |
| download | git-14c0ea0f6f7a0898214d8fa822a2392ef3a00f53.tar.xz | |
shallow: free grafts when unregistering them
When removing a graft via `unregister_shallow()` we remove it from the
grafts array, but do not free the structure. Fix this to plug the leak.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'shallow.c')
| -rw-r--r-- | shallow.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -51,10 +51,12 @@ int unregister_shallow(const struct object_id *oid) int pos = commit_graft_pos(the_repository, oid); if (pos < 0) return -1; - if (pos + 1 < the_repository->parsed_objects->grafts_nr) + if (pos + 1 < the_repository->parsed_objects->grafts_nr) { + free(the_repository->parsed_objects->grafts[pos]); MOVE_ARRAY(the_repository->parsed_objects->grafts + pos, the_repository->parsed_objects->grafts + pos + 1, the_repository->parsed_objects->grafts_nr - pos - 1); + } the_repository->parsed_objects->grafts_nr--; return 0; } |
