summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBo Xu <bo_xu@foxitsoftware.com>2014-05-27 10:55:08 -0700
committerBo Xu <bo_xu@foxitsoftware.com>2014-05-27 10:55:08 -0700
commit282e53ded7e9f3d1ee5792d53def1b172ae6bb65 (patch)
tree05d34feddb6845a9376d0ebfb3ee8ddbfc04d79d
parent2611932c1dea188078be8b59801285cbbdc0fcf1 (diff)
downloadpdfium-282e53ded7e9f3d1ee5792d53def1b172ae6bb65.tar.xz
Fix memory leak on array size overflow.
BUG=none R=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/300023002
-rw-r--r--core/src/fxcrt/fx_basic_array.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/core/src/fxcrt/fx_basic_array.cpp b/core/src/fxcrt/fx_basic_array.cpp
index 93f2b2fec5..aae3a1fa1c 100644
--- a/core/src/fxcrt/fx_basic_array.cpp
+++ b/core/src/fxcrt/fx_basic_array.cpp
@@ -1,7 +1,7 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../include/fxcrt/fx_basic.h"
@@ -25,7 +25,10 @@ CFX_BasicArray::~CFX_BasicArray()
FX_BOOL CFX_BasicArray::SetSize(int nNewSize, int nGrowBy)
{
if (nNewSize < 0 || nNewSize > (1 << 28) / m_nUnitSize) {
- m_pData = NULL;
+ if (m_pData != NULL) {
+ FX_Allocator_Free(m_pAllocator, m_pData);
+ m_pData = NULL;
+ }
m_nSize = m_nMaxSize = 0;
return FALSE;
}