Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: core/fxcrt/include/fx_basic.h

Issue 1998583002: Fix leak in CPDF_StreamContentParser::AddTextObject(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: CollectionSize Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfapi/fpdf_render/fpdf_render_text.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef CORE_FXCRT_INCLUDE_FX_BASIC_H_ 7 #ifndef CORE_FXCRT_INCLUDE_FX_BASIC_H_
8 #define CORE_FXCRT_INCLUDE_FX_BASIC_H_ 8 #define CORE_FXCRT_INCLUDE_FX_BASIC_H_
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 710
711 CFX_CountRef() { m_pObject = NULL; } 711 CFX_CountRef() { m_pObject = NULL; }
712 712
713 CFX_CountRef(const Ref& ref) { 713 CFX_CountRef(const Ref& ref) {
714 m_pObject = ref.m_pObject; 714 m_pObject = ref.m_pObject;
715 if (m_pObject) { 715 if (m_pObject) {
716 m_pObject->m_RefCount++; 716 m_pObject->m_RefCount++;
717 } 717 }
718 } 718 }
719 719
720 ~CFX_CountRef() { 720 ~CFX_CountRef() { SetNull(); }
721 if (!m_pObject) {
722 return;
723 }
724 m_pObject->m_RefCount--;
725 if (m_pObject->m_RefCount <= 0) {
726 delete m_pObject;
727 }
728 }
729 721
730 ObjClass* New() { 722 ObjClass* New() {
731 if (m_pObject) { 723 SetNull();
732 m_pObject->m_RefCount--;
733 if (m_pObject->m_RefCount <= 0) {
734 delete m_pObject;
735 }
736 }
737 m_pObject = new CountedObj; 724 m_pObject = new CountedObj;
738 m_pObject->m_RefCount = 1; 725 m_pObject->m_RefCount = 1;
739 return m_pObject; 726 return m_pObject;
740 } 727 }
741 728
742 void operator=(const Ref& ref) { 729 void operator=(const Ref& ref) {
743 if (ref.m_pObject) { 730 if (ref.m_pObject)
744 ref.m_pObject->m_RefCount++; 731 ref.m_pObject->m_RefCount++;
745 } 732 SetNull();
746 if (m_pObject) {
747 m_pObject->m_RefCount--;
748 if (m_pObject->m_RefCount <= 0) {
749 delete m_pObject;
750 }
751 }
752 m_pObject = ref.m_pObject; 733 m_pObject = ref.m_pObject;
753 } 734 }
754 735
755 void operator=(void* p) {
756 ASSERT(p == 0);
757 if (!m_pObject) {
758 return;
759 }
760 m_pObject->m_RefCount--;
761 if (m_pObject->m_RefCount <= 0) {
762 delete m_pObject;
763 }
764 m_pObject = NULL;
765 }
766
767 const ObjClass* GetObject() const { return m_pObject; } 736 const ObjClass* GetObject() const { return m_pObject; }
768 737
769 operator const ObjClass*() const { return m_pObject; } 738 operator const ObjClass*() const { return m_pObject; }
770 739
771 FX_BOOL IsNull() const { return !m_pObject; } 740 FX_BOOL IsNull() const { return !m_pObject; }
772 741
773 FX_BOOL NotNull() const { return !IsNull(); } 742 FX_BOOL NotNull() const { return !IsNull(); }
774 743
775 ObjClass* GetModify() { 744 ObjClass* GetModify() {
776 if (!m_pObject) { 745 if (!m_pObject) {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 FX_FLOAT c; 966 FX_FLOAT c;
998 FX_FLOAT d; 967 FX_FLOAT d;
999 FX_FLOAT e; 968 FX_FLOAT e;
1000 FX_FLOAT f; 969 FX_FLOAT f;
1001 FX_FLOAT g; 970 FX_FLOAT g;
1002 FX_FLOAT h; 971 FX_FLOAT h;
1003 FX_FLOAT i; 972 FX_FLOAT i;
1004 }; 973 };
1005 974
1006 #endif // CORE_FXCRT_INCLUDE_FX_BASIC_H_ 975 #endif // CORE_FXCRT_INCLUDE_FX_BASIC_H_
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_render/fpdf_render_text.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698