diff options
author | Chris Palmer <palmer@google.com> | 2014-07-23 15:00:32 -0700 |
---|---|---|
committer | Chris Palmer <palmer@google.com> | 2014-07-23 15:00:32 -0700 |
commit | a08cf99d066b16e4e16393efc15174193e002371 (patch) | |
tree | 8199f4122d1bdb2ca7211eb817002e97e11ee251 /core/include/fxcrt/fx_basic.h | |
parent | 141d61d1f6255923f46b6f0b97614e27c9c4dc86 (diff) | |
download | pdfium-chromium/2110.tar.xz |
Refactor CFX_BasicArray.chromium/2112chromium/2111chromium/2110chromium/2109chromium/2108chromium/2107chromium/2106chromium/2105chromium/2104
The |nGrowBy| argument to |SetSize| was always -1, which caused the
effective m_nGrowBy value to always be its default value: 0. So it was not
needed, and was cluttering up the logic.
BUG=384662
Check for integer overflow in CFX_BasicArray.
BUG=384662
R=bo_xu@foxitsoftware.com, rsesek@chromium.org
Review URL: https://codereview.chromium.org/415803002
Diffstat (limited to 'core/include/fxcrt/fx_basic.h')
-rw-r--r-- | core/include/fxcrt/fx_basic.h | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h index c400a940ff..ece2b43a2e 100644 --- a/core/include/fxcrt/fx_basic.h +++ b/core/include/fxcrt/fx_basic.h @@ -350,7 +350,7 @@ protected: ~CFX_BasicArray(); - FX_BOOL SetSize(int nNewSize, int nGrowBy); + FX_BOOL SetSize(int nNewSize); FX_BOOL Append(const CFX_BasicArray& src); @@ -371,8 +371,6 @@ protected: int m_nMaxSize; - int m_nGrowBy; - int m_nUnitSize; }; template<class TYPE> @@ -391,14 +389,14 @@ public: return m_nSize - 1; } - FX_BOOL SetSize(int nNewSize, int nGrowBy = -1) + FX_BOOL SetSize(int nNewSize) { - return CFX_BasicArray::SetSize(nNewSize, nGrowBy); + return CFX_BasicArray::SetSize(nNewSize); } void RemoveAll() { - SetSize(0, -1); + SetSize(0); } const TYPE GetAt(int nIndex) const @@ -442,7 +440,7 @@ public: return FALSE; } if (nIndex >= m_nSize) - if (!SetSize(nIndex + 1, -1)) { + if (!SetSize(nIndex + 1)) { return FALSE; } ((TYPE*)m_pData)[nIndex] = newElement; @@ -453,7 +451,7 @@ public: { if (m_nSize < m_nMaxSize) { m_nSize ++; - } else if (!SetSize(m_nSize + 1, -1)) { + } else if (!SetSize(m_nSize + 1)) { return FALSE; } ((TYPE*)m_pData)[m_nSize - 1] = newElement; @@ -616,7 +614,7 @@ public: return 0; } RemoveAll(); - SetSize(nCount, -1); + SetSize(nCount); ObjectClass* pStartObj = (ObjectClass*)m_pData; nSize = nStart + nCount; for (FX_INT32 i = nStart; i < nSize; i ++, pStartObj++) { @@ -653,7 +651,7 @@ public: for (int i = 0; i < m_nSize; i ++) { ((ObjectClass*)GetDataPtr(i))->~ObjectClass(); } - CFX_BasicArray::SetSize(0, -1); + CFX_BasicArray::SetSize(0); } }; typedef CFX_ObjectArray<CFX_ByteString> CFX_ByteStringArray; |