[PATCH 4/4] load_pack_mtimes_file(): avoid accessing uninitialized data
- From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Mar 27, 2025, 12:43 UTC
- Message-ID
- <d630e95b9672e6b4b3114c077f2995c5170a6a8f.1743079429.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1888.git.1743079429.gitgitgadget@gmail.com>
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; struct mtimes_header header; fd = git_open(mtimes_file);
-- gitgitgadget