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

Re: [PATCH] repository: cache->squash_msg is freed twice

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 19, 2025, 03:52 UTC
Message-ID
<xmqq4ipnxh5h.fsf@gitster.g>
In-Reply-To
<CAPig+cRsKGERBk2pVotrKhhy5FCmmrQODTJEgkO8GuTY2SLbiA@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 24 quoted lines
> On Thu, Dec 18, 2025 at 10:26 AM AZero13 via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
>> Thankfully, it is set to NULL, so no security consequences.
>> However, this is still a mistake that must be rectified.
>>
>> Signed-off-by: Greg Funni <gfunni234@gmail.com>
>> ---
>> diff --git a/repository.c b/repository.c
>> @@ -349,7 +349,6 @@ out:
>>  static void repo_clear_path_cache(struct repo_path_cache *cache)
>>  {
>> -       FREE_AND_NULL(cache->squash_msg);
>>         FREE_AND_NULL(cache->squash_msg);
>>         FREE_AND_NULL(cache->merge_msg);
>>         FREE_AND_NULL(cache->merge_rr);
>
> This mistake has been present since Ævar added this function in
> 759f340738 (repository.c: free the "path cache" in repo_clear(),
> 2022-03-04), so it isn't the result of someone else coming along and
> adding a new field to the structure which needs freeing but then
> botching the call to FREE_AND_NULL(). Moreover, this function does
> free all the freeable members of repo_path_cache, hence, nothing is
> being leaked, so it must have just been a silly copy/paste mistake in
> the first place. Hence, this change makes sense.
Thanks, both.  Will queue.
Previous: Eric Sunshine
Message 4 of 4 in “repository: cache->squash_msg is freed twice”
  1. repository: cache->squash_msg is freed twiceAZero13 via GitGitGadget, Dec 18, 2025
  2. repository: remove duplicate free of cache->squash_msgAZero13 via GitGitGadget, Dec 18, 2025
  3. Eric SunshineDec 18, 2025
  4. Junio C HamanoDec 19, 2025

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.