From 7354cbe4635a35aad2a6c1a77fac457084341714 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Wed, 11 Dec 2024 14:17:51 +0100 Subject: [PATCH] Fix core::array::reallocate when shrinking --- irr/include/irrArray.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/irr/include/irrArray.h b/irr/include/irrArray.h index 4a87382bc..834dc825c 100644 --- a/irr/include/irrArray.h +++ b/irr/include/irrArray.h @@ -59,8 +59,12 @@ public: { size_t allocated = m_data.capacity(); if (new_size < allocated) { - if (canShrink) - m_data.resize(new_size); + if (canShrink) { + // since capacity != size don't accidentally make it bigger + if (m_data.size() > new_size) + m_data.resize(new_size); + m_data.shrink_to_fit(); + } } else { m_data.reserve(new_size); }