From bdef97d52c0c16b66334cd76abac366af3a2ec7b Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Mon, 30 Mar 2026 17:31:16 -0700 Subject: [PATCH] utils: Prevent capacity overflow in StructureOfArrays scaling logic --- libs/utils/include/utils/StructureOfArrays.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/utils/include/utils/StructureOfArrays.h b/libs/utils/include/utils/StructureOfArrays.h index 923744beed..e5e8328b8d 100644 --- a/libs/utils/include/utils/StructureOfArrays.h +++ b/libs/utils/include/utils/StructureOfArrays.h @@ -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); } }