diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-04-03 16:32:19 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-03 16:32:19 +0000 |
commit | 232b918d1f0faec230652f4097b834257a7dbb27 (patch) | |
tree | c13213ab3d70cc147a6ea59b0f090a51beecae8f /core/fpdfapi | |
parent | 36d7ad4a24287b562e1d88fcde635e36a167bfe3 (diff) | |
download | pdfium-232b918d1f0faec230652f4097b834257a7dbb27.tar.xz |
Re-arrange so inline vectors come last in structs.
This might make the memory tools more effective in finding OOBs.
Change-Id: Id093bb0a88c37954c80d612ac00b5a168e75bdbf
Reviewed-on: https://pdfium-review.googlesource.com/29550
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r-- | core/fpdfapi/font/cpdf_cidfont.h | 2 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_cmapparser.h | 2 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_simplefont.h | 6 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_colorspace.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_meshstream.h | 4 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_psengine.h | 3 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_streamcontentparser.h | 4 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_crypto_handler.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_crypto_handler.h | 2 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_security_handler.h | 4 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_syntax_parser.cpp | 3 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_syntax_parser.h | 6 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_renderstatus.cpp | 16 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_type3cache.cpp | 3 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_type3glyphs.h | 4 |
15 files changed, 35 insertions, 32 deletions
diff --git a/core/fpdfapi/font/cpdf_cidfont.h b/core/fpdfapi/font/cpdf_cidfont.h index 68fce2ccb6..0bf5f7ace1 100644 --- a/core/fpdfapi/font/cpdf_cidfont.h +++ b/core/fpdfapi/font/cpdf_cidfont.h @@ -81,13 +81,13 @@ class CPDF_CIDFont : public CPDF_Font { uint16_t m_DefaultWidth; RetainPtr<CPDF_StreamAcc> m_pStreamAcc; bool m_bAnsiWidthsFixed; - FX_RECT m_CharBBox[256]; std::vector<uint32_t> m_WidthList; short m_DefaultVY; short m_DefaultW1; std::vector<uint32_t> m_VertMetrics; bool m_bAdobeCourierStd; std::unique_ptr<CFX_CTTGSUBTable> m_pTTGSUBTable; + FX_RECT m_CharBBox[256]; }; #endif // CORE_FPDFAPI_FONT_CPDF_CIDFONT_H_ diff --git a/core/fpdfapi/font/cpdf_cmapparser.h b/core/fpdfapi/font/cpdf_cmapparser.h index fc46c58f72..c70d408f90 100644 --- a/core/fpdfapi/font/cpdf_cmapparser.h +++ b/core/fpdfapi/font/cpdf_cmapparser.h @@ -40,10 +40,10 @@ class CPDF_CMapParser { UnownedPtr<CPDF_CMap> const m_pCMap; int m_Status; int m_CodeSeq; - uint32_t m_CodePoints[4]; std::vector<CPDF_CMap::CodeRange> m_CodeRanges; std::vector<CPDF_CMap::CIDRange> m_AdditionalCharcodeToCIDMappings; ByteString m_LastWord; + uint32_t m_CodePoints[4]; }; #endif // CORE_FPDFAPI_FONT_CPDF_CMAPPARSER_H_ diff --git a/core/fpdfapi/font/cpdf_simplefont.h b/core/fpdfapi/font/cpdf_simplefont.h index 9cb730d1a1..3aa68d73a6 100644 --- a/core/fpdfapi/font/cpdf_simplefont.h +++ b/core/fpdfapi/font/cpdf_simplefont.h @@ -39,13 +39,13 @@ class CPDF_SimpleFont : public CPDF_Font { void LoadCharMetrics(int charcode); CPDF_FontEncoding m_Encoding; + int m_BaseEncoding; + bool m_bUseFontWidth; + std::vector<ByteString> m_CharNames; uint16_t m_GlyphIndex[256]; uint16_t m_ExtGID[256]; - std::vector<ByteString> m_CharNames; - int m_BaseEncoding; uint16_t m_CharWidth[256]; FX_RECT m_CharBBox[256]; - bool m_bUseFontWidth; }; #endif // CORE_FPDFAPI_FONT_CPDF_SIMPLEFONT_H_ diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp index fde0ed4dad..e1dd598a63 100644 --- a/core/fpdfapi/page/cpdf_colorspace.cpp +++ b/core/fpdfapi/page/cpdf_colorspace.cpp @@ -89,9 +89,9 @@ class CPDF_CalGray : public CPDF_ColorSpace { bool bTransMask) const override; private: + float m_Gamma; float m_WhitePoint[3]; float m_BlackPoint[3]; - float m_Gamma; }; class CPDF_CalRGB : public CPDF_ColorSpace { @@ -112,12 +112,12 @@ class CPDF_CalRGB : public CPDF_ColorSpace { int image_height, bool bTransMask) const override; + bool m_bGamma; + bool m_bMatrix; float m_WhitePoint[3]; float m_BlackPoint[3]; float m_Gamma[3]; float m_Matrix[9]; - bool m_bGamma; - bool m_bMatrix; }; class CPDF_LabCS : public CPDF_ColorSpace { diff --git a/core/fpdfapi/page/cpdf_meshstream.h b/core/fpdfapi/page/cpdf_meshstream.h index 7c34b25185..9c97e09c15 100644 --- a/core/fpdfapi/page/cpdf_meshstream.h +++ b/core/fpdfapi/page/cpdf_meshstream.h @@ -78,10 +78,10 @@ class CPDF_MeshStream { float m_xmax; float m_ymin; float m_ymax; - float m_ColorMin[kMaxComponents]; - float m_ColorMax[kMaxComponents]; RetainPtr<CPDF_StreamAcc> m_pStream; std::unique_ptr<CFX_BitStream> m_BitStream; + float m_ColorMin[kMaxComponents]; + float m_ColorMax[kMaxComponents]; }; #endif // CORE_FPDFAPI_PAGE_CPDF_MESHSTREAM_H_ diff --git a/core/fpdfapi/page/cpdf_psengine.h b/core/fpdfapi/page/cpdf_psengine.h index 8a054cc9e6..042a1c0895 100644 --- a/core/fpdfapi/page/cpdf_psengine.h +++ b/core/fpdfapi/page/cpdf_psengine.h @@ -120,9 +120,10 @@ class CPDF_PSEngine { private: static constexpr uint32_t kPSEngineStackSize = 100; - float m_Stack[kPSEngineStackSize]; + uint32_t m_StackCount; CPDF_PSProc m_MainProc; + float m_Stack[kPSEngineStackSize]; }; #endif // CORE_FPDFAPI_PAGE_CPDF_PSENGINE_H_ diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h index de4a92fc99..5dcfbe5308 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.h +++ b/core/fpdfapi/page/cpdf_streamcontentparser.h @@ -201,7 +201,6 @@ class CPDF_StreamContentParser { UnownedPtr<std::set<const uint8_t*>> const m_ParsedSet; CFX_Matrix m_mtContentToUser; const CFX_FloatRect m_BBox; - ContentParam m_ParamBuf[kParamBufSize]; uint32_t m_ParamStartPos; uint32_t m_ParamCount; CPDF_StreamParser* m_pSyntax; @@ -219,9 +218,10 @@ class CPDF_StreamContentParser { ByteString m_LastImageName; RetainPtr<CPDF_Image> m_pLastImage; bool m_bColored; - float m_Type3Data[6]; bool m_bResourceMissing; std::vector<std::unique_ptr<CPDF_AllStates>> m_StateStack; + float m_Type3Data[6]; + ContentParam m_ParamBuf[kParamBufSize]; }; #endif // CORE_FPDFAPI_PAGE_CPDF_STREAMCONTENTPARSER_H_ diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.cpp b/core/fpdfapi/parser/cpdf_crypto_handler.cpp index d963df4887..c27f9dc9fc 100644 --- a/core/fpdfapi/parser/cpdf_crypto_handler.cpp +++ b/core/fpdfapi/parser/cpdf_crypto_handler.cpp @@ -110,9 +110,9 @@ void CPDF_CryptoHandler::CryptBlock(bool bEncrypt, struct AESCryptContext { bool m_bIV; - uint8_t m_Block[16]; uint32_t m_BlockOffset; CRYPT_aes_context m_Context; + uint8_t m_Block[16]; }; void* CPDF_CryptoHandler::CryptStart(uint32_t objnum, diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.h b/core/fpdfapi/parser/cpdf_crypto_handler.h index 32eeaef4c9..1ca2130717 100644 --- a/core/fpdfapi/parser/cpdf_crypto_handler.h +++ b/core/fpdfapi/parser/cpdf_crypto_handler.h @@ -69,10 +69,10 @@ class CPDF_CryptoHandler { bool bEncrypt); bool CryptFinish(void* context, CFX_BinaryBuf& dest_buf, bool bEncrypt); - uint8_t m_EncryptKey[32]; int m_KeyLen; int m_Cipher; std::unique_ptr<CRYPT_aes_context, FxFreeDeleter> m_pAESContext; + uint8_t m_EncryptKey[32]; }; #endif // CORE_FPDFAPI_PARSER_CPDF_CRYPTO_HANDLER_H_ diff --git a/core/fpdfapi/parser/cpdf_security_handler.h b/core/fpdfapi/parser/cpdf_security_handler.h index eb9574386e..177c25f29a 100644 --- a/core/fpdfapi/parser/cpdf_security_handler.h +++ b/core/fpdfapi/parser/cpdf_security_handler.h @@ -88,14 +88,14 @@ class CPDF_SecurityHandler { int m_Version; int m_Revision; - UnownedPtr<const CPDF_Dictionary> m_pEncryptDict; ByteString m_FileId; uint32_t m_Permissions; int m_Cipher; - uint8_t m_EncryptKey[32]; int m_KeyLen; bool m_bOwnerUnlocked; + UnownedPtr<const CPDF_Dictionary> m_pEncryptDict; std::unique_ptr<CPDF_CryptoHandler> m_pCryptoHandler; + uint8_t m_EncryptKey[32]; }; #endif // CORE_FPDFAPI_PARSER_CPDF_SECURITY_HANDLER_H_ diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp index 8b8e59fa96..245617dca1 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp @@ -40,8 +40,7 @@ enum class ReadStatus { Normal, Backslash, Octal, FinishOctal, CarriageReturn }; // static int CPDF_SyntaxParser::s_CurrentRecursionDepth = 0; -CPDF_SyntaxParser::CPDF_SyntaxParser() - : m_pFileAccess(nullptr), m_pPool(WeakPtr<ByteStringPool>()) {} +CPDF_SyntaxParser::CPDF_SyntaxParser() = default; CPDF_SyntaxParser::~CPDF_SyntaxParser() = default; diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.h b/core/fpdfapi/parser/cpdf_syntax_parser.h index 50c20fc115..5aad2e463c 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.h +++ b/core/fpdfapi/parser/cpdf_syntax_parser.h @@ -92,14 +92,14 @@ class CPDF_SyntaxParser { ParseType parse_type); FX_FILESIZE m_Pos; - RetainPtr<CPDF_ReadValidator> m_pFileAccess; FX_FILESIZE m_HeaderOffset; FX_FILESIZE m_FileLen; + WeakPtr<ByteStringPool> m_pPool; std::vector<uint8_t> m_pFileBuf; + RetainPtr<CPDF_ReadValidator> m_pFileAccess; FX_FILESIZE m_BufOffset; - uint8_t m_WordBuffer[257]; uint32_t m_WordSize; - WeakPtr<ByteStringPool> m_pPool; + uint8_t m_WordBuffer[257]; }; #endif // CORE_FPDFAPI_PARSER_CPDF_SYNTAX_PARSER_H_ diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index d5204fe500..367519ac83 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -696,7 +696,6 @@ int BiInterpolImpl(int c0, struct Coon_Color { Coon_Color() { memset(comp, 0, sizeof(int) * 3); } - int comp[3]; // Returns true if successful, false if overflow detected. bool BiInterpol(Coon_Color colors[4], @@ -717,16 +716,12 @@ struct Coon_Color { return std::max({abs(comp[0] - o.comp[0]), abs(comp[1] - o.comp[1]), abs(comp[2] - o.comp[2])}); } + + int comp[3]; }; #define COONCOLOR_THRESHOLD 4 struct CPDF_PatchDrawer { - Coon_Color patch_colors[4]; - int max_delta; - CFX_PathData path; - CFX_RenderDevice* pDevice; - int fill_mode; - int alpha; void Draw(int x_scale, int y_scale, int left, @@ -825,6 +820,13 @@ struct CPDF_PatchDrawer { } } } + + int max_delta; + CFX_PathData path; + CFX_RenderDevice* pDevice; + int fill_mode; + int alpha; + Coon_Color patch_colors[4]; }; void DrawCoonPatchMeshes( diff --git a/core/fpdfapi/render/cpdf_type3cache.cpp b/core/fpdfapi/render/cpdf_type3cache.cpp index fe9dfbf9e0..33a440f1ca 100644 --- a/core/fpdfapi/render/cpdf_type3cache.cpp +++ b/core/fpdfapi/render/cpdf_type3cache.cpp @@ -21,8 +21,9 @@ namespace { struct CPDF_UniqueKeyGen { void Generate(int count, ...); - char m_Key[128]; + int m_KeyLen; + char m_Key[128]; }; void CPDF_UniqueKeyGen::Generate(int count, ...) { diff --git a/core/fpdfapi/render/cpdf_type3glyphs.h b/core/fpdfapi/render/cpdf_type3glyphs.h index 778b639642..7756be309f 100644 --- a/core/fpdfapi/render/cpdf_type3glyphs.h +++ b/core/fpdfapi/render/cpdf_type3glyphs.h @@ -24,10 +24,10 @@ class CPDF_Type3Glyphs { void AdjustBlue(float top, float bottom, int& top_line, int& bottom_line); std::map<uint32_t, std::unique_ptr<CFX_GlyphBitmap>> m_GlyphMap; - int m_TopBlue[TYPE3_MAX_BLUES]; - int m_BottomBlue[TYPE3_MAX_BLUES]; int m_TopBlueCount; int m_BottomBlueCount; + int m_TopBlue[TYPE3_MAX_BLUES]; + int m_BottomBlue[TYPE3_MAX_BLUES]; }; #endif // CORE_FPDFAPI_RENDER_CPDF_TYPE3GLYPHS_H_ |