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

github.com/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2022-11-12 01:42:45 +0300
committerTaylor Blau <me@ttaylorr.com>2022-11-12 01:42:45 +0300
commit777b8c737312e54f1450b256405bf5c09e996381 (patch)
tree87ad58a6b27d67eb36e690fab29c90a27873b866
parentc28a592b0f345c30fbfb05ad0337f83a83a9bd8f (diff)
parent586d8b5052f6b98c262c872f54216e39f3d56625 (diff)
Merge branch 'sg/plug-line-log-leaks' into seen
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
-rw-r--r--diff.c17
-rw-r--r--diffcore.h1
-rw-r--r--line-log.c7
3 files changed, 13 insertions, 12 deletions
diff --git a/diff.c b/diff.c
index 9f9a92ec9d2..1054a4b7329 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);
diff --git a/diffcore.h b/diffcore.h
index badc2261c20..9b588a1ee15 100644
--- a/diffcore.h
+++ b/diffcore.h
@@ -162,6 +162,7 @@ struct diff_filepair *diff_queue(struct diff_queue_struct *,
struct diff_filespec *,
struct diff_filespec *);
void diff_q(struct diff_queue_struct *, struct diff_filepair *);
+void diff_free_queue(struct diff_queue_struct *q);
/* dir_rename_relevance: the reason we want rename information for a dir */
enum dir_rename_relevance {
diff --git a/line-log.c b/line-log.c
index 51d93310a4d..a7f3e7f6ce4 100644
--- a/line-log.c
+++ b/line-log.c
@@ -1089,10 +1089,8 @@ static struct diff_filepair *diff_filepair_dup(struct diff_filepair *pair)
static void free_diffqueues(int n, struct diff_queue_struct *dq)
{
- int i, j;
- for (i = 0; i < n; i++)
- for (j = 0; j < dq[i].nr; j++)
- diff_free_filepair(dq[i].queue[j]);
+ for (int i = 0; i < n; i++)
+ diff_free_queue(&dq[i]);
free(dq);
}
@@ -1195,6 +1193,7 @@ static int process_ranges_ordinary_commit(struct rev_info *rev, struct commit *c
if (parent)
add_line_range(rev, parent, parent_range);
free_line_log_data(parent_range);
+ diff_free_queue(&queue);
return changed;
}