public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: lidongyan <502024330056@smail.nju.edu.cn>
Cc: Alex via GitGitGadget <gitgitgadget@gmail.com>,
	 git@vger.kernel.org, Alex <alexguo1023@gmail.com>,
	 jinyaoguo <guo846@purdue.edu>
Subject: Re: [PATCH] Allocate msg only after fatal checks to avoid leaks
Date: Sat, 14 Jun 2025 08:40:43 -0700	[thread overview]
Message-ID: <xmqqcyb672mc.fsf@gitster.g> (raw)
In-Reply-To: <3993AF96-E03D-46AB-B18E-8E6C1108EC45@smail.nju.edu.cn> (lidongyan's message of "Sat, 14 Jun 2025 16:26:09 +0800")

lidongyan <502024330056@smail.nju.edu.cn> writes:

> Alex via GitGitGadget <gitgitgadget@gmail.com> writes:
>> 
>> From: jinyaoguo <guo846@purdue.edu>
>> 
>> 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.

  reply	other threads:[~2025-06-14 15:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-13 19:32 [PATCH] Allocate msg only after fatal checks to avoid leaks Alex via GitGitGadget
2025-06-13 20:37 ` Junio C Hamano
2025-06-14  8:26 ` lidongyan
2025-06-14 15:40   ` Junio C Hamano [this message]
2025-06-14 15:50     ` lidongyan
2025-06-14 23:01     ` Jeff King
2025-06-15  0:45       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqcyb672mc.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=502024330056@smail.nju.edu.cn \
    --cc=alexguo1023@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=guo846@purdue.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox