From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Git List <git@vger.kernel.org>, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 2/9] test-tool path-utils: fix a memory leak
Date: Fri, 01 Jul 2022 11:24:56 +0200 [thread overview]
Message-ID: <220701.86k08xb2w4.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <CAPig+cT5jETAi5extz2tHwSzp4a=b7qqaK0S=mcjQr1m_1jAQQ@mail.gmail.com>
On Fri, Jul 01 2022, Eric Sunshine wrote:
> On Thu, Jun 30, 2022 at 7:51 PM Ævar Arnfjörð Bjarmason
> <avarab@gmail.com> wrote:
>> Fix a memory leak in "test-tool path-utils", as a result we can mark
>> the corresponding test as passing with SANITIZE=leak using
>> "TEST_PASSES_SANITIZE_LEAK=true".
>>
>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
>> ---
>> diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c
>> @@ -294,11 +294,13 @@ static int protect_ntfs_hfs_benchmark(int argc, const char **argv)
>> int cmd__path_utils(int argc, const char **argv)
>> {
>> if (argc == 3 && !strcmp(argv[1], "normalize_path_copy")) {
>> - char *buf = xmallocz(strlen(argv[2]));
>> + char *to_free = NULL;
>> + char *buf = to_free = xmallocz(strlen(argv[2]));
>
> Is there a non-obvious reason that `to_free` is initialized to NULL
> before being immediately overwritten with the result of xmallocz()?
>
> Also, pure nit, but it may be a bit more idiomatic (though I could be
> wrong) written as:
>
> char *buf, *to_free;
> buf = to_free = xmallocz(...);
Thanks, I'll change it to be like that. I wouldn't put "= NULL" there
normally, that part snuck in from some earlier version, and escaped my
own pre-review.
next prev parent reply other threads:[~2022-07-01 9:26 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-30 23:47 [PATCH 0/9] test-tool: fix memory leaks Ævar Arnfjörð Bjarmason
2022-06-30 23:47 ` [PATCH 1/9] test-tool test-hash: fix a memory leak Ævar Arnfjörð Bjarmason
2022-06-30 23:47 ` [PATCH 2/9] test-tool path-utils: " Ævar Arnfjörð Bjarmason
2022-07-01 4:27 ` Eric Sunshine
2022-07-01 9:24 ` Ævar Arnfjörð Bjarmason [this message]
2022-06-30 23:47 ` [PATCH 3/9] test-tool {dump,scrap}-cache-tree: fix memory leaks Ævar Arnfjörð Bjarmason
2022-06-30 23:47 ` [PATCH 4/9] test-tool urlmatch-normalization: fix a memory leak Ævar Arnfjörð Bjarmason
2022-06-30 23:47 ` [PATCH 5/9] test-tool regex: call regfree(), fix memory leaks Ævar Arnfjörð Bjarmason
2022-07-01 2:17 ` Junio C Hamano
2022-06-30 23:47 ` [PATCH 6/9] test-tool json-writer: " Ævar Arnfjörð Bjarmason
2022-06-30 23:47 ` [PATCH 7/9] test-tool bloom: fix a memory leak Ævar Arnfjörð Bjarmason
2022-07-01 4:34 ` Eric Sunshine
2022-07-01 9:25 ` Ævar Arnfjörð Bjarmason
2022-06-30 23:47 ` [PATCH 8/9] test-tool ref-store: " Ævar Arnfjörð Bjarmason
2022-06-30 23:47 ` [PATCH 9/9] test-tool delta: " Ævar Arnfjörð Bjarmason
2022-07-01 10:37 ` [PATCH v2 0/9] test-tool: fix memory leaks Ævar Arnfjörð Bjarmason
2022-07-01 10:37 ` [PATCH v2 1/9] test-tool test-hash: fix a memory leak Ævar Arnfjörð Bjarmason
2022-07-01 10:37 ` [PATCH v2 2/9] test-tool path-utils: " Ævar Arnfjörð Bjarmason
2022-07-01 20:43 ` Junio C Hamano
2022-07-01 10:37 ` [PATCH v2 3/9] test-tool {dump,scrap}-cache-tree: fix memory leaks Ævar Arnfjörð Bjarmason
2022-07-01 10:37 ` [PATCH v2 4/9] test-tool urlmatch-normalization: fix a memory leak Ævar Arnfjörð Bjarmason
2022-07-01 10:37 ` [PATCH v2 5/9] test-tool regex: call regfree(), fix memory leaks Ævar Arnfjörð Bjarmason
2022-07-01 10:37 ` [PATCH v2 6/9] test-tool json-writer: " Ævar Arnfjörð Bjarmason
2022-07-01 10:37 ` [PATCH v2 7/9] test-tool bloom: " Ævar Arnfjörð Bjarmason
2022-07-01 10:37 ` [PATCH v2 8/9] test-tool ref-store: fix a memory leak Ævar Arnfjörð Bjarmason
2022-07-01 10:37 ` [PATCH v2 9/9] test-tool delta: " Ævar Arnfjörð Bjarmason
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=220701.86k08xb2w4.gmgdl@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sunshine@sunshineco.com \
/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;
as well as URLs for NNTP newsgroup(s).