summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2019-08-08 10:44:57 +0200
committerPatrick Steinhardt <ps@pks.im>2019-08-23 12:54:01 +0200
commita477bff11054540219e9a2920aab18cf44dbdba4 (patch)
tree7d835067d347d64cd68eb410c012968ca8417f35
parentd4fe402b0523a3065fbe6c7c2d3ae5a208eb18e4 (diff)
downloadlibgit2-a477bff11054540219e9a2920aab18cf44dbdba4.tar.gz
indexer: catch OOM when adding expected OIDs
When adding OIDs to the indexer's map of yet-to-be-seen OIDs to verify that packfiles are complete, we do so by first allocating a new OID and then calling `git_oidmap_set` on it. There was no check for memory allocation errors in place, though, leading to possible segfaults due to trying to copy data to a `NULL` pointer. Verify the result of `git__malloc` with `GIT_ERROR_CHECK_ALLOC` to fix the issue.
-rw-r--r--src/indexer.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/indexer.c b/src/indexer.c
index e7b3483fb..84b950d13 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -326,6 +326,7 @@ static int add_expected_oid(git_indexer *idx, const git_oid *oid)
!git_oidmap_exists(idx->pack->idx_cache, oid) &&
!git_oidmap_exists(idx->expected_oids, oid)) {
git_oid *dup = git__malloc(sizeof(*oid));
+ GIT_ERROR_CHECK_ALLOC(dup);
git_oid_cpy(dup, oid);
return git_oidmap_set(idx->expected_oids, dup, dup);
}