Re: [PATCH v2 1/2] merge-ort: fix small memory leak in detect_and_process_renames()
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Feb 21, 2022, 02:35 UTC
- Message-ID
- <YhL6i3x1l4qwQJg+@nand.local>
- In-Reply-To
- <f1f7fc97fe2fe5079365bb91c71fb7033378995d.1645320592.git.gitgitgadget@gmail.com>
On Sun, Feb 20, 2022 at 01:29:50AM +0000, Elijah Newren via GitGitGadget wrote:
> merge-ort.c | 15 +++++---------- > 1 file changed, 5 insertions(+), 10 deletions(-)
Both versions of this patch look good to me (in fact, I appreciated seeing both v1 and v2, since v1 makes it more obvious what is changing, but v2 does the whole thing in a little bit of a cleaner way).
Show 13 quoted lines
> diff --git a/merge-ort.c b/merge-ort.c
> index d85b1cd99e9..3d7f9feb6f7 100644
> --- a/merge-ort.c
> +++ b/merge-ort.c
> @@ -3086,12 +3086,11 @@ static int detect_and_process_renames(struct merge_options *opt,
> struct tree *side1,
> struct tree *side2)
> {
> - struct diff_queue_struct combined;
> + struct diff_queue_struct combined = { 0 };
> struct rename_info *renames = &opt->priv->renames;
> - int need_dir_renames, s, clean = 1;
> + int need_dir_renames, s, i, clean = 1;And this entire patch looks good to me, but I did wonder about why "i" is an int here. Shouldn't it be a size_t instead? Looking at diff_queue_struct's definition, both "alloc" and "nr" are signed ints, when they should almost certainly be unsigned to avoid overflow.
Thanks, Taylor