Skip to content

Commit a827560

Browse files
committed
fsck: avoid using an uninitialized variable
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 <[email protected]>
1 parent b85d18c commit a827560

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ static int fsck_commit(const struct object_id *oid,
925925
{
926926
struct object_id tree_oid, parent_oid;
927927
unsigned author_count;
928-
int err;
928+
int err = 0;
929929
const char *buffer_begin = buffer;
930930
const char *buffer_end = buffer + size;
931931
const char *p;

0 commit comments

Comments
 (0)