From: Taylor Blau <me@ttaylorr.com>
To: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH 4/4] load_pack_mtimes_file(): avoid accessing uninitialized data
Date: Thu, 27 Mar 2025 10:24:25 -0400 [thread overview]
Message-ID: <Z+VfmZ4RZ5OjU/ed@nand.local> (raw)
In-Reply-To: <d630e95b9672e6b4b3114c077f2995c5170a6a8f.1743079429.git.gitgitgadget@gmail.com>
On Thu, Mar 27, 2025 at 12:43:49PM +0000, Johannes Schindelin via GitGitGadget wrote:
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> The `mtimes_size` variable is uninitialzed when the function errors out,
> yet its value is assigned to another variable. Let's just initialize it.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> pack-mtimes.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/pack-mtimes.c b/pack-mtimes.c
> index cdf30b8d2b0..c1f531d45a0 100644
> --- a/pack-mtimes.c
> +++ b/pack-mtimes.c
> @@ -29,7 +29,7 @@ static int load_pack_mtimes_file(char *mtimes_file,
> int fd, ret = 0;
> struct stat st;
> uint32_t *data = NULL;
> - size_t mtimes_size, expected_size;
> + size_t mtimes_size = 0, expected_size;
Hmm. This one follows an identical line of reasoning as in my previous
response in the thread. So I think this one is likewise unnecessary
(though not harmful, and certainly useful if it appeases static analysis
tools, etc).
Thanks,
Taylor
next prev parent reply other threads:[~2025-03-27 14:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-27 12:43 [PATCH 0/4] Initialize a few uninitialized variables Johannes Schindelin via GitGitGadget
2025-03-27 12:43 ` [PATCH 1/4] cat_one_file(): make it easy to see that the `size` variable is initialized Johannes Schindelin via GitGitGadget
2025-03-28 3:46 ` Jeff King
2025-03-27 12:43 ` [PATCH 2/4] fsck: avoid using an uninitialized variable Johannes Schindelin via GitGitGadget
2025-03-28 4:07 ` Jeff King
2025-03-27 12:43 ` [PATCH 3/4] load_revindex_from_disk(): avoid accessing uninitialized data Johannes Schindelin via GitGitGadget
2025-03-27 14:23 ` Taylor Blau
2025-03-27 12:43 ` [PATCH 4/4] load_pack_mtimes_file(): " Johannes Schindelin via GitGitGadget
2025-03-27 14:24 ` Taylor Blau [this message]
2025-07-17 16:45 ` [PATCH 0/4] Initialize a few uninitialized variables Johannes Schindelin
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=Z+VfmZ4RZ5OjU/ed@nand.local \
--to=me@ttaylorr.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=johannes.schindelin@gmx.de \
/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).