From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH 2/4] fsck: avoid using an uninitialized variable
Date: Thu, 27 Mar 2025 12:43:47 +0000 [thread overview]
Message-ID: <575b4b2c2b8a5e800bb65b99f1fcdd6aaae63f94.1743079429.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1888.git.1743079429.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
In `fsck_commit()`, after counting the authors of a commit, we set the
`err` variable either when there was no author, or when there were more
than two authors recorded. Then we access the `err` variable to figure
out whether we should return early. But if there was exactly one author,
that variable is still uninitialized.
Let's just initialize the variable.
This issue was pointed out by CodeQL.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
fsck.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fsck.c b/fsck.c
index 9fc4c25ffd5..ad04b24ff13 100644
--- a/fsck.c
+++ b/fsck.c
@@ -925,7 +925,7 @@ static int fsck_commit(const struct object_id *oid,
{
struct object_id tree_oid, parent_oid;
unsigned author_count;
- int err;
+ int err = 0;
const char *buffer_begin = buffer;
const char *buffer_end = buffer + size;
const char *p;
--
gitgitgadget
next prev parent reply other threads:[~2025-03-27 12:43 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 ` Johannes Schindelin via GitGitGadget [this message]
2025-03-28 4:07 ` [PATCH 2/4] fsck: avoid using an uninitialized variable 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
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=575b4b2c2b8a5e800bb65b99f1fcdd6aaae63f94.1743079429.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--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).