diff options
author | Edward Thomson <ethomson@microsoft.com> | 2015-02-12 12:19:37 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2015-02-13 09:27:33 -0500 |
commit | f1453c59b2afb9dab43281bfe9f1ba34cf6e0d02 (patch) | |
tree | cb189e211547042080f35227b7e4d3f9b0c8ac2a /src/pack-objects.c | |
parent | 650e45f69124bd8b53ecefddeb214a82538ab2c1 (diff) | |
download | libgit2-f1453c59b2afb9dab43281bfe9f1ba34cf6e0d02.tar.gz |
Make our overflow check look more like gcc/clang's
Make our overflow checking look more like gcc and clang's, so that
we can substitute it out with the compiler instrinsics on platforms
that support it. This means dropping the ability to pass `NULL` as
an out parameter.
As a result, the macros also get updated to reflect this as well.
Diffstat (limited to 'src/pack-objects.c')
-rw-r--r-- | src/pack-objects.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/pack-objects.c b/src/pack-objects.c index 8236ef9f3..67d6125ff 100644 --- a/src/pack-objects.c +++ b/src/pack-objects.c @@ -202,9 +202,8 @@ int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid, return 0; if (pb->nr_objects >= pb->nr_alloc) { - GITERR_CHECK_ALLOC_ADD(pb->nr_alloc, 1024); - GITERR_CHECK_ALLOC_MULTIPLY(pb->nr_alloc + 1024, 3 / 2); - newsize = (pb->nr_alloc + 1024) * 3 / 2; + GITERR_CHECK_ALLOC_ADD(&newsize, pb->nr_alloc, 1024); + GITERR_CHECK_ALLOC_MULTIPLY(&newsize, newsize, 3 / 2); if (!git__is_uint32(newsize)) { giterr_set(GITERR_NOMEMORY, "Packfile too large to fit in memory."); @@ -833,7 +832,7 @@ static int try_delta(git_packbuilder *pb, struct unpacked *trg, trg_object->delta_data = NULL; } if (delta_cacheable(pb, src_size, trg_size, delta_size)) { - if (!git__add_uint64_overflow(&pb->delta_cache_size, pb->delta_cache_size, delta_size)) + if (git__add_uint64_overflow(&pb->delta_cache_size, pb->delta_cache_size, delta_size)) return -1; git_packbuilder__cache_unlock(pb); |