From 9e194394c3370d6e9b5bdf71f47a9977d1411fe4 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 23 Jul 2005 16:58:10 +0000 Subject: [PATCH] CVector fix - corrupt memory on size change --- dlls/engine/CVector.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dlls/engine/CVector.h b/dlls/engine/CVector.h index 05538f53..d6b87eb5 100755 --- a/dlls/engine/CVector.h +++ b/dlls/engine/CVector.h @@ -48,7 +48,8 @@ template class CVector return false; if (m_Data) { - memcpy(newData, m_Data, m_Size * sizeof(T)); + for (size_t i=0; i class CVector return false; if (m_Data) { - memcpy(newData, m_Data, (m_Size < size) ? (m_Size * sizeof(T)) : (size * sizeof(T))); + size_t end = (m_Size < size) ? (m_Size) : size; + for (size_t i=0; i(const CVector & other) { // copy data - m_Data = new T [other.m_Size]; - m_Size = other.m_Size; + m_Data = new T [other.m_CurrentUsedSize]; + m_Size = other.m_CurrentUsedSize; m_CurrentUsedSize = other.m_CurrentUsedSize; - memcpy(m_Data, other.m_Data, m_CurrentUsedSize * sizeof(T)); + for (size_t i=0; i()