git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

Previous: Phillip WoodNext: Stefan Beller
Message 12 of 21 in “diff --color-moved-ws: fix double free crash”
  1. 1/5 diff --color-moved-ws: fix double free crashPhillip Wood, Oct 2, 2018
  2. 2/5 diff --color-moved-ws: fix out of bounds string accessPhillip Wood, Oct 2, 2018
  3. Stefan BellerOct 2, 2018
  4. Phillip WoodOct 3, 2018
  5. 3/5 diff --color-moved-ws: fix a memory leakPhillip Wood, Oct 2, 2018
  6. Stefan BellerOct 2, 2018
  7. Phillip WoodOct 3, 2018
  8. Martin ÅgrenOct 3, 2018
  9. 4/5 diff --color-moved-ws: fix another memory leakPhillip Wood, Oct 2, 2018
  10. Stefan BellerOct 2, 2018
  11. 5/5 diff --color-moved: fix a memory leakPhillip Wood, Oct 2, 2018
  12. Stefan BellerOct 2, 2018
  13. Stefan BellerOct 2, 2018
  14. Phillip WoodOct 3, 2018
  15. 0/5 diff --color-moved-ws: fix double free crashPhillip Wood, Oct 4, 2018
  16. 2/5 diff --color-moved-ws: fix out of bounds string accessPhillip Wood, Oct 4, 2018
  17. 3/5 diff --color-moved-ws: fix a memory leakPhillip Wood, Oct 4, 2018
  18. 5/5 diff --color-moved: fix a memory leakPhillip Wood, Oct 4, 2018
  19. Stefan BellerOct 4, 2018
  20. 4/5 diff --color-moved-ws: fix another memory leakPhillip Wood, Oct 4, 2018
  21. 1/5 diff --color-moved-ws: fix double free crashPhillip Wood, Oct 4, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.