From 4f6fdbe6adf0d90886b9deb5666996603cf1207c Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 9 Mar 2016 13:24:25 -0800 Subject: Structs shouldn't inherit from CFX_Target. There are some assumptions in the code that CAPS_NAMED structs are POD, and can be memcpy'd, malloc'd, etc. CFX_Target adds a virtual dtor, which is not what is desired for many of these, so resolve by making each a CAPS_Named class or by removing the inheritence. In the process XFA_TextPiece was found to be malloc'd despite having a ctor. Move this to |new|, noting that the object is never freed (and goes out of existence when the allocator's pool is destroyed). BUG=pdfium:432 R=dsinclair@chromium.org Review URL: https://codereview.chromium.org/1780753002 . --- xfa/src/fxfa/app/xfa_textlayout.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'xfa/src/fxfa/app/xfa_textlayout.h') diff --git a/xfa/src/fxfa/app/xfa_textlayout.h b/xfa/src/fxfa/app/xfa_textlayout.h index bcace9d9d6..2d8d1bf15e 100644 --- a/xfa/src/fxfa/app/xfa_textlayout.h +++ b/xfa/src/fxfa/app/xfa_textlayout.h @@ -243,9 +243,10 @@ class CXFA_TextUserData : public IFX_Unknown, public CFX_Target { FX_DWORD m_dwRefCount; }; -struct XFA_TEXTPIECE : public CFX_Target { - XFA_TEXTPIECE() : pszText(nullptr), pFont(nullptr), pLinkData(nullptr) {} - ~XFA_TEXTPIECE() { +class XFA_TextPiece : public CFX_Target { + public: + XFA_TextPiece() : pszText(nullptr), pFont(nullptr), pLinkData(nullptr) {} + ~XFA_TextPiece() { if (pLinkData) pLinkData->Release(); } @@ -265,7 +266,7 @@ struct XFA_TEXTPIECE : public CFX_Target { CFX_RectF rtPiece; CXFA_LinkUserData* pLinkData; }; -typedef CFX_ArrayTemplate CXFA_PieceArray; +typedef CFX_ArrayTemplate CXFA_PieceArray; class CXFA_PieceLine : public CFX_Target { public: @@ -399,10 +400,10 @@ class CXFA_TextLayout { int32_t iPiece, FXTEXT_CHARPOS* pCharPos, const CFX_Matrix& tmDoc2Device); - int32_t GetDisplayPos(const XFA_TEXTPIECE* pPiece, + int32_t GetDisplayPos(const XFA_TextPiece* pPiece, FXTEXT_CHARPOS* pCharPos, FX_BOOL bCharCode = FALSE); - FX_BOOL ToRun(const XFA_TEXTPIECE* pPiece, FX_RTFTEXTOBJ& tr); + FX_BOOL ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ& tr); void DoTabstops(IFDE_CSSComputedStyle* pStyle, CXFA_PieceLine* pPieceLine); FX_BOOL Layout(int32_t iBlock); int32_t CountBlocks() const; -- cgit v1.2.3