Author: mjansen
Date: Sat Sep 17 17:54:16 2016
New Revision: 72705

URL: http://svn.reactos.org/svn/reactos?rev=72705&view=rev
Log:
[ATL] Do not corrupt the internal state of the CSimpleArray when allocation 
fails. Patch by Katayama Hirofumi MZ. CORE-11946 #comment Committed, thanks!

Modified:
    trunk/reactos/sdk/lib/atl/atlsimpcoll.h

Modified: trunk/reactos/sdk/lib/atl/atlsimpcoll.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/atl/atlsimpcoll.h?rev=72705&r1=72704&r2=72705&view=diff
==============================================================================
--- trunk/reactos/sdk/lib/atl/atlsimpcoll.h     [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/atl/atlsimpcoll.h     [iso-8859-1] Sat Sep 17 
17:54:16 2016
@@ -182,16 +182,17 @@
         {
             RemoveAll();
 
-            m_nCapacity = src.GetSize();
-
-            T *pNewData = (T *)realloc(m_pData, m_nCapacity * sizeof(T));
+            int nNewCount = src.GetSize();
+
+            T *pNewData = (T *)realloc(m_pData, nNewCount * sizeof(T));
             ATLASSERT(pNewData);
             if (pNewData == NULL)
                 return *this;   // failure
 
-            // store new data and capacity
+            // store new
             m_pData = pNewData;
-            m_nCount = m_nCapacity;
+            m_nCount = nNewCount;
+            m_nCapacity = nNewCount;
         }
         else
         {


Reply via email to