utils: Prevent capacity overflow in StructureOfArrays scaling logic
This commit is contained in:
committed by
Mathias Agopian
parent
0016c0808b
commit
bdef97d52c
@@ -295,7 +295,7 @@ public:
|
||||
void ensureCapacity(size_t needed) {
|
||||
if (UTILS_UNLIKELY(needed > mCapacity)) {
|
||||
// not enough space, increase the capacity
|
||||
const size_t capacity = (needed * 3 + 1) / 2;
|
||||
const size_t capacity = (needed > SIZE_MAX / 3) ? needed : (needed * 3 + 1) / 2;
|
||||
setCapacity(capacity);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user