From 282e53ded7e9f3d1ee5792d53def1b172ae6bb65 Mon Sep 17 00:00:00 2001 From: Bo Xu Date: Tue, 27 May 2014 10:55:08 -0700 Subject: Fix memory leak on array size overflow. BUG=none R=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/300023002 --- core/src/fxcrt/fx_basic_array.cpp | 7 +++++-- 1 file 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; } -- cgit v1.2.3