diff options
author | thestig <thestig@chromium.org> | 2016-08-09 15:46:20 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-09 15:46:20 -0700 |
commit | dc359b03ab6a70ee52a91119ff6704cae92f4809 (patch) | |
tree | 131cb9b1846f4be24c9cb7c54b30975c6a858071 /core/fpdfapi/fpdf_page/include | |
parent | 39ba18a64283ef3fc3c4aedf537a09835f90862e (diff) | |
download | pdfium-dc359b03ab6a70ee52a91119ff6704cae92f4809.tar.xz |
Fix a leak with FPDFPageObj_NewImgeObj().
BUG=pdfium:545
Review-Url: https://codereview.chromium.org/2194393002
Diffstat (limited to 'core/fpdfapi/fpdf_page/include')
-rw-r--r-- | core/fpdfapi/fpdf_page/include/cpdf_image.h | 20 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/include/cpdf_imageobject.h | 11 |
2 files changed, 18 insertions, 13 deletions
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_image.h b/core/fpdfapi/fpdf_page/include/cpdf_image.h index f475e53478..ef48a04f95 100644 --- a/core/fpdfapi/fpdf_page/include/cpdf_image.h +++ b/core/fpdfapi/fpdf_page/include/cpdf_image.h @@ -28,12 +28,9 @@ class IFX_Pause; class CPDF_Image { public: explicit CPDF_Image(CPDF_Document* pDoc); + CPDF_Image(CPDF_Document* pDoc, CPDF_Stream* pStream, bool bInline); ~CPDF_Image(); - FX_BOOL LoadImageF(CPDF_Stream* pImageStream, FX_BOOL bInline); - - void Release(); - CPDF_Image* Clone(); CPDF_Dictionary* GetInlineDict() const { return m_pInlineDict; } @@ -47,9 +44,9 @@ class CPDF_Image { int32_t GetPixelHeight() const { return m_Height; } int32_t GetPixelWidth() const { return m_Width; } - FX_BOOL IsInline() { return m_bInline; } - FX_BOOL IsMask() const { return m_bIsMask; } - FX_BOOL IsInterpol() const { return m_bInterpolate; } + bool IsInline() const { return m_bInline; } + bool IsMask() const { return m_bIsMask; } + bool IsInterpol() const { return m_bInterpolate; } CFX_DIBSource* LoadDIBSource(CFX_DIBSource** ppMask = nullptr, uint32_t* pMatteColor = nullptr, @@ -59,7 +56,6 @@ class CPDF_Image { void SetInlineDict(CPDF_Dictionary* pDict) { m_pInlineDict = pDict; } void SetImage(const CFX_DIBitmap* pDIBitmap, int32_t iCompress); - void SetJpegImage(uint8_t* pImageData, uint32_t size); void SetJpegImage(IFX_FileRead* pFile); void ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pDIBitmap); @@ -81,13 +77,13 @@ class CPDF_Image { CPDF_Dictionary* InitJPEG(uint8_t* pData, uint32_t size); CPDF_Stream* m_pStream; - FX_BOOL m_bInline; + const bool m_bInline; CPDF_Dictionary* m_pInlineDict; int32_t m_Height; int32_t m_Width; - FX_BOOL m_bIsMask; - FX_BOOL m_bInterpolate; - CPDF_Document* m_pDocument; + bool m_bIsMask; + bool m_bInterpolate; + CPDF_Document* const m_pDocument; CPDF_Dictionary* m_pOC; }; diff --git a/core/fpdfapi/fpdf_page/include/cpdf_imageobject.h b/core/fpdfapi/fpdf_page/include/cpdf_imageobject.h index b2bffa707c..fdbd43c4a9 100644 --- a/core/fpdfapi/fpdf_page/include/cpdf_imageobject.h +++ b/core/fpdfapi/fpdf_page/include/cpdf_imageobject.h @@ -7,6 +7,8 @@ #ifndef CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_IMAGEOBJECT_H_ #define CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_IMAGEOBJECT_H_ +#include <memory> + #include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" #include "core/fxcrt/include/fx_coordinates.h" @@ -27,9 +29,16 @@ class CPDF_ImageObject : public CPDF_PageObject { void CalcBoundingBox(); CPDF_Image* GetImage() const { return m_pImage; } + void SetOwnedImage(std::unique_ptr<CPDF_Image> pImage); + void SetUnownedImage(CPDF_Image* pImage); - CPDF_Image* m_pImage; CFX_Matrix m_Matrix; + + private: + void Release(); + + CPDF_Image* m_pImage; + bool m_pImageOwned; }; #endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_IMAGEOBJECT_H_ |