diff options
author | erwin coumans <erwin.coumans@gmail.com> | 2022-04-25 18:31:07 -0700 |
---|---|---|
committer | erwin coumans <erwin.coumans@gmail.com> | 2022-04-25 18:31:07 -0700 |
commit | 9185f93174d5e24f06dbec6bb4c2868fd72617ed (patch) | |
tree | d1d0dff8bd386c0bd539cde5c224c4e4b2c8119c | |
parent | 9eb945b1e846cf2a3d074ec4c2625dd0b4fc9875 (diff) | |
download | bullet3-9185f93174d5e24f06dbec6bb4c2868fd72617ed.tar.gz |
manually copy data, to avoid possible memory leaks.
-rw-r--r-- | src/Bullet3Common/b3AlignedObjectArray.h | 12 |
1 files 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) |