Skip to content

Commit 90450d8

Browse files
committed
indexer: check return code of git_hash_ctx_init
Initialization of the hashing context may fail on some systems, most notably on Win32 via the legacy hashing context. As such, we need to always check the error code of `git_hash_ctx_init`, which is not done when creating a new indexer. Fix the issue by adding checks.
1 parent 6eebfc0 commit 90450d8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/indexer.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ int git_indexer_new(
150150
idx->progress_cb = opts.progress_cb;
151151
idx->progress_payload = opts.progress_cb_payload;
152152
idx->mode = mode ? mode : GIT_PACK_FILE_MODE;
153-
git_hash_ctx_init(&idx->hash_ctx);
154-
git_hash_ctx_init(&idx->trailer);
155153
git_buf_init(&idx->entry_data, 0);
156154

157-
if ((error = git_oidmap_new(&idx->expected_oids)) < 0)
155+
if ((error = git_hash_ctx_init(&idx->hash_ctx)) < 0 ||
156+
(error = git_hash_ctx_init(&idx->trailer)) < 0 ||
157+
(error = git_oidmap_new(&idx->expected_oids)) < 0)
158158
goto cleanup;
159159

160160
idx->do_verify = opts.verify;

0 commit comments

Comments
 (0)