Skip to content

Commit a43bde2

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 830ecd3 commit a43bde2

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
@@ -926,7 +926,7 @@ static int fsck_commit(const struct object_id *oid,
926926
{
927927
struct object_id tree_oid, parent_oid;
928928
unsigned author_count;
929-
int err;
929+
int err = 0;
930930
const char *buffer_begin = buffer;
931931
const char *buffer_end = buffer + size;
932932
const char *p;

0 commit comments

Comments
 (0)