Re: [PATCH 5/5] diff --color-moved: fix a memory leak
- From
Stefan Beller <sbeller@google.com>
- Date
- Oct 2, 2018, 19:11 UTC
- Message-ID
- <CAGZ79kZDEeBZbTC=yb3CcJz54GM4jn_669H3T1fiNXs9Oob7aA@mail.gmail.com>
- In-Reply-To
- <20181002175514.31495-5-phillip.wood@talktalk.net>
On Tue, Oct 2, 2018 at 10:55 AM Phillip Wood <phillip.wood@talktalk.net> wrote:
Show 23 quoted lines
> > From: Phillip Wood <phillip.wood@dunelm.org.uk> > > Free the hashmap items as well as the hashmap itself. This was found > with asan. > > Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> > --- > diff.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/diff.c b/diff.c > index 4464feacf8..94cc1b5592 100644 > --- a/diff.c > +++ b/diff.c > @@ -5770,8 +5770,8 @@ static void diff_flush_patch_all_file_pairs(struct diff_options *o) > if (o->color_moved == COLOR_MOVED_ZEBRA_DIM) > dim_moved_lines(o); > > - hashmap_free(&add_lines, 0); > - hashmap_free(&del_lines, 0); > + hashmap_free(&add_lines, 1); > + hashmap_free(&del_lines, 1);
And this is sufficient as the entries themselves are moved_entry, which only contain pointers (to o->emitted_symbols), which are freed later. There is nothing in there that needs extra free-ing.
Thanks, Stefan