From aa575d4805bf7a9e83f00b56e38d4de39d90f95c Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Fri, 10 Jul 2015 15:40:59 -0700 Subject: Make CJBig2_Object::operator delete accept nullptr Standard delete operator should do noting for nullptr. Overloaded CJBig2_Object::operator delete de-referenced provided pointer causing crashes after https://codereview.chromium.org/1192743004/ TBR=thestig BUG=508197 Review URL: https://codereview.chromium.org/1230763007 . --- core/src/fxcodec/jbig2/JBig2_Object.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'core/src/fxcodec') diff --git a/core/src/fxcodec/jbig2/JBig2_Object.cpp b/core/src/fxcodec/jbig2/JBig2_Object.cpp index 1429a91644..ae544d72d5 100644 --- a/core/src/fxcodec/jbig2/JBig2_Object.cpp +++ b/core/src/fxcodec/jbig2/JBig2_Object.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 "JBig2_Object.h" @@ -26,7 +26,9 @@ void *CJBig2_Object::operator new(size_t size, CJBig2_Module *pModule) } void CJBig2_Object::operator delete(void *p) { - ((CJBig2_Object *)p)->m_pModule->JBig2_Free(p); + if (p) { + ((CJBig2_Object *)p)->m_pModule->JBig2_Free(p); + } } void CJBig2_Object::operator delete(void *p, CJBig2_Module *pModule) { @@ -64,7 +66,9 @@ void *CJBig2_Object::operator new[](size_t size, CJBig2_Module *pModule, size_t } void CJBig2_Object::operator delete[](void* p) { - ((CJBig2_Object *)p)->m_pModule->JBig2_Free(p); + if (p) { + ((CJBig2_Object *)p)->m_pModule->JBig2_Free(p); + } } void CJBig2_Object::operator delete[](void *p, CJBig2_Module *pModule, size_t unit_size) { -- cgit v1.2.3