Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-11-28 06:13:45 +0300
committerJunio C Hamano <gitster@pobox.com>2022-11-28 06:13:46 +0300
commit613999cc5c951bc2c078caad59e339243f119a6e (patch)
treebf60befea6698e410499e2e7cacdc93a48cf9967 /diff.c
parent91c43cde25852e91245c2e801b9153aff5f67c6a (diff)
parent586d8b5052f6b98c262c872f54216e39f3d56625 (diff)
Merge branch 'sg/plug-line-log-leaks'
A handful of leaks in the line-log machinery have been plugged. * sg/plug-line-log-leaks: diff.c: use diff_free_queue() line-log: free the diff queues' arrays when processing merge commits line-log: free diff queue when processing non-merge commits
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/diff.c b/diff.c
index 9f9a92ec9d..1054a4b732 100644
--- a/diff.c
+++ b/diff.c
@@ -5772,6 +5772,13 @@ void diff_free_filepair(struct diff_filepair *p)
free(p);
}
+void diff_free_queue(struct diff_queue_struct *q)
+{
+ for (int i = 0; i < q->nr; i++)
+ diff_free_filepair(q->queue[i]);
+ free(q->queue);
+}
+
const char *diff_aligned_abbrev(const struct object_id *oid, int len)
{
int abblen;
@@ -6329,13 +6336,9 @@ static int diff_get_patch_id(struct diff_options *options, struct object_id *oid
int diff_flush_patch_id(struct diff_options *options, struct object_id *oid, int diff_header_only)
{
struct diff_queue_struct *q = &diff_queued_diff;
- int i;
int result = diff_get_patch_id(options, oid, diff_header_only);
- for (i = 0; i < q->nr; i++)
- diff_free_filepair(q->queue[i]);
-
- free(q->queue);
+ diff_free_queue(q);
DIFF_QUEUE_CLEAR(q);
return result;
@@ -6604,10 +6607,8 @@ void diff_flush(struct diff_options *options)
if (output_format & DIFF_FORMAT_CALLBACK)
options->format_callback(q, options, options->format_callback_data);
- for (i = 0; i < q->nr; i++)
- diff_free_filepair(q->queue[i]);
free_queue:
- free(q->queue);
+ diff_free_queue(q);
DIFF_QUEUE_CLEAR(q);
diff_free(options);