summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-02-25 15:47:36 -0800
committerJunio C Hamano <gitster@pobox.com>2022-02-25 15:47:36 -0800
commit362f869ff2dbc389234ecd8c4b996a9e507c39d7 (patch)
tree077586c50787e0a4469311aa15e7059f731825c5
parent0a01df08c03fe707e22795de7bd1d763ed02e9e1 (diff)
parent6ee36364eb32287f071878a91d3bbcd86313754a (diff)
downloadgit-362f869ff2dbc389234ecd8c4b996a9e507c39d7.tar.gz
Merge branch 'ab/diff-free-more'
Leakfixes. * ab/diff-free-more: diff.[ch]: have diff_free() free options->parseopts diff.[ch]: have diff_free() call clear_pathspec(opts.pathspec)
-rw-r--r--add-interactive.c6
-rw-r--r--blame.c3
-rw-r--r--builtin/reset.c1
-rw-r--r--diff.c2
-rw-r--r--notes-merge.c2
5 files changed, 5 insertions, 9 deletions
diff --git a/add-interactive.c b/add-interactive.c
index 6498ae196f..e1ab39cce3 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -797,14 +797,14 @@ static int run_revert(struct add_i_state *s, const struct pathspec *ps,
diffopt.flags.override_submodule_config = 1;
diffopt.repo = s->r;
- if (do_diff_cache(&oid, &diffopt))
+ if (do_diff_cache(&oid, &diffopt)) {
+ diff_free(&diffopt);
res = -1;
- else {
+ } else {
diffcore_std(&diffopt);
diff_flush(&diffopt);
}
free(paths);
- clear_pathspec(&diffopt.pathspec);
if (!res && write_locked_index(s->r->index, &index_lock,
COMMIT_LOCK) < 0)
diff --git a/blame.c b/blame.c
index 083d99fdbc..186ad96120 100644
--- a/blame.c
+++ b/blame.c
@@ -1403,7 +1403,6 @@ static struct blame_origin *find_origin(struct repository *r,
}
}
diff_flush(&diff_opts);
- clear_pathspec(&diff_opts.pathspec);
return porigin;
}
@@ -1447,7 +1446,6 @@ static struct blame_origin *find_rename(struct repository *r,
}
}
diff_flush(&diff_opts);
- clear_pathspec(&diff_opts.pathspec);
return porigin;
}
@@ -2328,7 +2326,6 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,
} while (unblamed);
target->suspects = reverse_blame(leftover, NULL);
diff_flush(&diff_opts);
- clear_pathspec(&diff_opts.pathspec);
}
/*
diff --git a/builtin/reset.c b/builtin/reset.c
index 75b8d86481..6e65e90c5d 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -280,7 +280,6 @@ static int read_from_tree(const struct pathspec *pathspec,
return 1;
diffcore_std(&opt);
diff_flush(&opt);
- clear_pathspec(&opt.pathspec);
return 0;
}
diff --git a/diff.c b/diff.c
index 7d5cfd325e..c4ccb6b1a3 100644
--- a/diff.c
+++ b/diff.c
@@ -6452,6 +6452,8 @@ void diff_free(struct diff_options *options)
diff_free_file(options);
diff_free_ignore_regex(options);
+ clear_pathspec(&options->pathspec);
+ FREE_AND_NULL(options->parseopts);
}
void diff_flush(struct diff_options *options)
diff --git a/notes-merge.c b/notes-merge.c
index 01d596920e..878b6c571b 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -175,7 +175,6 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
oid_to_hex(&mp->remote));
}
diff_flush(&opt);
- clear_pathspec(&opt.pathspec);
*num_changes = len;
return changes;
@@ -261,7 +260,6 @@ static void diff_tree_local(struct notes_merge_options *o,
oid_to_hex(&mp->local));
}
diff_flush(&opt);
- clear_pathspec(&opt.pathspec);
}
static void check_notes_merge_worktree(struct notes_merge_options *o)