diff options
author | Patrick Steinhardt <ps@pks.im> | 2020-02-07 12:10:12 +0100 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2020-02-07 13:08:23 +0100 |
commit | 90450d8825e01e2deb24e0f9bd244a9efe243528 (patch) | |
tree | cd524d1084fe0a66e8f15b790096578850e2553b | |
parent | 6eebfc06989c42132f58b9f0b40283b067dd8613 (diff) | |
download | libgit2-90450d8825e01e2deb24e0f9bd244a9efe243528.tar.gz |
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.
-rw-r--r-- | src/indexer.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/indexer.c b/src/indexer.c index 717549fa2..68fdd85c5 100644 --- a/src/indexer.c +++ b/src/indexer.c @@ -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; |