From 9185f93174d5e24f06dbec6bb4c2868fd72617ed Mon Sep 17 00:00:00 2001 From: erwin coumans Date: Mon, 25 Apr 2022 18:31:07 -0700 Subject: [PATCH] manually copy data, to avoid possible memory leaks. --- src/Bullet3Common/b3AlignedObjectArray.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Bullet3Common/b3AlignedObjectArray.h b/src/Bullet3Common/b3AlignedObjectArray.h index 7d31b56d0..8ef3331f7 100644 --- a/src/Bullet3Common/b3AlignedObjectArray.h +++ b/src/Bullet3Common/b3AlignedObjectArray.h @@ -135,7 +135,11 @@ public: int otherSize = otherArray.size(); resize(otherSize); - otherArray.copy(0, otherSize, m_data); + //don't use otherArray.copy, it can leak memory + for (int i = 0; i < otherSize; i++) + { + m_data[i] = otherArray[i]; + } } /// return the number of elements in the array @@ -506,7 +510,11 @@ public: { int otherSize = otherArray.size(); resize(otherSize); - otherArray.copy(0, otherSize, m_data); + //don't use otherArray.copy, it can leak memory + for (int i = 0; i < otherSize; i++) + { + m_data[i] = otherArray[i]; + } } void removeAtIndex(int index)