diff --git a/include/reactphysics3d/containers/Deque.h b/include/reactphysics3d/containers/Deque.h index 7658c1b5..e837028f 100644 --- a/include/reactphysics3d/containers/Deque.h +++ b/include/reactphysics3d/containers/Deque.h @@ -293,14 +293,16 @@ class Deque { /// Destructor ~Deque() { + if (mCapacity > 0) { - clear(); + clear(); - // Release the chunks array - mAllocator.release(mBuffer, sizeof(T) * mCapacity); + // Release the chunks array + mAllocator.release(mBuffer, sizeof(T) * mCapacity); - mCapacity = 0; - mBuffer = nullptr; + mCapacity = 0; + mBuffer = nullptr; + } } /// Add an element at the end of the deque