Commit 0f07d54b by Edward Thomson

pack-objects: unlock the cache on integer overflow

parent d97d9559
......@@ -832,13 +832,14 @@ 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))
return -1;
bool overflow = git__add_uint64_overflow(
&pb->delta_cache_size, pb->delta_cache_size, delta_size);
git_packbuilder__cache_unlock(pb);
trg_object->delta_data = git__realloc(delta_buf, delta_size);
GITERR_CHECK_ALLOC(trg_object->delta_data);
if (overflow ||
!(trg_object->delta_data = git__realloc(delta_buf, delta_size)))
return -1;
} else {
/* create delta when writing the pack */
git_packbuilder__cache_unlock(pb);
......
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