diff --git a/src/s2/util/gtl/compact_array.h b/src/s2/util/gtl/compact_array.h index cbc4fe9a..033db144 100644 --- a/src/s2/util/gtl/compact_array.h +++ b/src/s2/util/gtl/compact_array.h @@ -413,8 +413,10 @@ class compact_array_base { value_allocator_type allocator; T* new_ptr = allocator.allocate(capacity()); - memcpy(new_ptr, Array(), old_capacity * sizeof(T)); - allocator.deallocate(Array(), old_capacity); + if (old_capacity != 0) { + memcpy(new_ptr, Array(), old_capacity * sizeof(T)); + allocator.deallocate(Array(), old_capacity); + } SetArray(new_ptr); }