Subject: Re: [PATCH] Allocate msg only after fatal checks to avoid leaks

From: Junio C Hamano <[email-masked]>
Date: Sat, 14 Jun 2025 08:40:43 -0700

lidongyan <[email-masked]> writes:

> Alex via GitGitGadget <[email-masked]> writes：
>> 
>> From: jinyaoguo <[email-masked]>
>> 
>> In parse_reuse_arg, we previously called xmalloc and strbuf_init
>> before resolving the ref and reading the object, leading to a
>> leaked msg on die() paths. This change moves the allocation of
>
> A memory leak on the die() path shouldn't be considered a real leak,
> right? Since the OS will clean up all memory once the process
> terminates, explicitly freeing msg isn't necessary in this case.

It may not matter in practice, but I think the leak checking
machinery like sanitizers would still complain, so I view efforts on
plugging such leaks in the error code paths more about decluttering
the leak checker output to help us spot the real leaks.