diff options
| author | Toon Claes <toon@iotcl.com> | 2026-01-30 15:26:36 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-01-30 08:57:01 -0800 |
| commit | e2505ec170bc0861c3b902bc9763416c5f222455 (patch) | |
| tree | 97644d402013a3e1fb20bbe4bf29d1cd5d3af558 | |
| parent | 85329e31dd4c864a5a200d0a0ded886599adc2c5 (diff) | |
| download | git-e2505ec170bc0861c3b902bc9763416c5f222455.tar.xz | |
last-modified: fix memory leak when more than one commit is given
When more than one commit is given, the function
populate_paths_from_revs() leaks a `struct pathspec`. Plug it.
Signed-off-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
| -rw-r--r-- | builtin/last-modified.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/builtin/last-modified.c b/builtin/last-modified.c index 1219f6802e..31dea975a0 100644 --- a/builtin/last-modified.c +++ b/builtin/last-modified.c @@ -123,7 +123,7 @@ static void add_path_from_diff(struct diff_queue_struct *q, static int populate_paths_from_revs(struct last_modified *lm) { - int num_interesting = 0; + int num_interesting = 0, ret = 0; struct diff_options diffopt; /* @@ -145,16 +145,20 @@ static int populate_paths_from_revs(struct last_modified *lm) if (obj->item->flags & UNINTERESTING) continue; - if (num_interesting++) - return error(_("last-modified can only operate on one commit at a time")); + if (num_interesting++) { + ret = error(_("last-modified can only operate on one commit at a time")); + goto out; + } diff_tree_oid(lm->rev.repo->hash_algo->empty_tree, &obj->item->oid, "", &diffopt); diff_flush(&diffopt); } + +out: clear_pathspec(&diffopt.pathspec); - return 0; + return ret; } static void last_modified_emit(struct last_modified *lm, |
