Commit 90450d88 by Patrick Steinhardt

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.
parent 6eebfc06
......@@ -150,11 +150,11 @@ int git_indexer_new(
idx->progress_cb = opts.progress_cb;
idx->progress_payload = opts.progress_cb_payload;
idx->mode = mode ? mode : GIT_PACK_FILE_MODE;
git_hash_ctx_init(&idx->hash_ctx);
git_hash_ctx_init(&idx->trailer);
git_buf_init(&idx->entry_data, 0);
if ((error = git_oidmap_new(&idx->expected_oids)) < 0)
if ((error = git_hash_ctx_init(&idx->hash_ctx)) < 0 ||
(error = git_hash_ctx_init(&idx->trailer)) < 0 ||
(error = git_oidmap_new(&idx->expected_oids)) < 0)
goto cleanup;
idx->do_verify = opts.verify;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment