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

Side by Side Diff: core/fxcrt/cfx_string_data_template.h

Issue 2364673002: Null CPDF_CountedObj::m_pObj prior to deletion (Closed)
Patch Set: Copy comment from strings header, fix old comment Created 4 years, 2 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_page/cpdf_countedobject.h ('k') | core/fxcrt/include/cfx_count_ref.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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_CFX_STRING_DATA_TEMPLATE_H_ 7 #ifndef CORE_FXCRT_CFX_STRING_DATA_TEMPLATE_H_
8 #define CORE_FXCRT_CFX_STRING_DATA_TEMPLATE_H_ 8 #define CORE_FXCRT_CFX_STRING_DATA_TEMPLATE_H_
9 9
10 #include "core/fxcrt/include/fx_memory.h" 10 #include "core/fxcrt/include/fx_memory.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 ASSERT(offset >= 0 && nLen >= 0 && offset + nLen <= m_nAllocLength); 78 ASSERT(offset >= 0 && nLen >= 0 && offset + nLen <= m_nAllocLength);
79 FXSYS_memcpy(m_String + offset, pStr, nLen * sizeof(CharType)); 79 FXSYS_memcpy(m_String + offset, pStr, nLen * sizeof(CharType));
80 m_String[offset + nLen] = 0; 80 m_String[offset + nLen] = 0;
81 } 81 }
82 82
83 // To ensure ref counts do not overflow, consider the worst possible case: 83 // To ensure ref counts do not overflow, consider the worst possible case:
84 // the entire address space contains nothing but pointers to this object. 84 // the entire address space contains nothing but pointers to this object.
85 // Since the count increments with each new pointer, the largest value is 85 // Since the count increments with each new pointer, the largest value is
86 // the number of pointers that can fit into the address space. The size of 86 // the number of pointers that can fit into the address space. The size of
87 // the address space itself is a good upper bound on it. 87 // the address space itself is a good upper bound on it.
88 intptr_t m_nRefs; // Would prefer ssize_t, but no windows support. 88 intptr_t m_nRefs;
89 89
90 // |FX_STRSIZE| is currently typedef'd as |int|. 90 // |FX_STRSIZE| is currently typedef'd as |int|.
91 // TODO(palmer): It should be a |size_t|, or at least unsigned. 91 // TODO(palmer): It should be a |size_t|, or at least unsigned.
92 // These lengths are in terms of number of characters, not bytes, and do not 92 // These lengths are in terms of number of characters, not bytes, and do not
93 // include the terminating NUL character, but the underlying buffer is sized 93 // include the terminating NUL character, but the underlying buffer is sized
94 // to be capable of holding it. 94 // to be capable of holding it.
95 FX_STRSIZE m_nDataLength; 95 FX_STRSIZE m_nDataLength;
96 FX_STRSIZE m_nAllocLength; 96 FX_STRSIZE m_nAllocLength;
97 97
98 // Not really 1, variable size. 98 // Not really 1, variable size.
99 CharType m_String[1]; 99 CharType m_String[1];
100 100
101 private: 101 private:
102 CFX_StringDataTemplate(FX_STRSIZE dataLen, FX_STRSIZE allocLen) 102 CFX_StringDataTemplate(FX_STRSIZE dataLen, FX_STRSIZE allocLen)
103 : m_nRefs(0), m_nDataLength(dataLen), m_nAllocLength(allocLen) { 103 : m_nRefs(0), m_nDataLength(dataLen), m_nAllocLength(allocLen) {
104 ASSERT(dataLen >= 0); 104 ASSERT(dataLen >= 0);
105 ASSERT(dataLen <= allocLen); 105 ASSERT(dataLen <= allocLen);
106 m_String[dataLen] = 0; 106 m_String[dataLen] = 0;
107 } 107 }
108 108
109 ~CFX_StringDataTemplate() = delete; 109 ~CFX_StringDataTemplate() = delete;
110 }; 110 };
111 111
112 extern template class CFX_StringDataTemplate<FX_CHAR>; 112 extern template class CFX_StringDataTemplate<FX_CHAR>;
113 extern template class CFX_StringDataTemplate<FX_WCHAR>; 113 extern template class CFX_StringDataTemplate<FX_WCHAR>;
114 114
115 #endif // CORE_FXCRT_CFX_STRING_DATA_TEMPLATE_H_ 115 #endif // CORE_FXCRT_CFX_STRING_DATA_TEMPLATE_H_
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_page/cpdf_countedobject.h ('k') | core/fxcrt/include/cfx_count_ref.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698