Skip to content

Commit 7e7472a

Browse files
committed
Fix SmallArray::add_array bug causing exponential memory allocation
1 parent 44e3ed4 commit 7e7472a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Source/Utility/Containers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ class SmallArrayImpl : public SmallArrayTemplateBase<T> {
808808
template<typename U>
809809
void add_array(U const& array)
810810
{
811-
this->reserve(this->capacity() + array.size());
811+
this->reserve(std::max<size_t>(this->capacity(), array.size()));
812812
for (auto const& elt : array)
813813
this->add(elt);
814814
}

0 commit comments

Comments
 (0)