summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-12-11 22:10:29 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-12-11 22:10:29 +0000
commit4412f3d87441c135ef56420f18d9229fbe247c3e (patch)
tree3a7250242f7bf0c254ea6038871f4e8aa2d536a2 /core/fpdfapi/parser
parentcb22f9ad9265f40b1104ed2b09488ccc6ec9e5aa (diff)
downloadpdfium-4412f3d87441c135ef56420f18d9229fbe247c3e.tar.xz
Slightly simplify CPDF_StreamAcc::LoadAllData().
Also initialize members in the header. Change-Id: Ic1cda7f9ef4c69e26604c706678aed24bf4e8ee3 Reviewed-on: https://pdfium-review.googlesource.com/20790 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser')
-rw-r--r--core/fpdfapi/parser/cpdf_stream_acc.cpp18
-rw-r--r--core/fpdfapi/parser/cpdf_stream_acc.h10
2 files changed, 12 insertions, 16 deletions
diff --git a/core/fpdfapi/parser/cpdf_stream_acc.cpp b/core/fpdfapi/parser/cpdf_stream_acc.cpp
index b539117bd3..5792a80d14 100644
--- a/core/fpdfapi/parser/cpdf_stream_acc.cpp
+++ b/core/fpdfapi/parser/cpdf_stream_acc.cpp
@@ -9,12 +9,7 @@
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
CPDF_StreamAcc::CPDF_StreamAcc(const CPDF_Stream* pStream)
- : m_pData(nullptr),
- m_dwSize(0),
- m_bNewBuf(false),
- m_pImageParam(nullptr),
- m_pStream(pStream),
- m_pSrcData(nullptr) {}
+ : m_pStream(pStream) {}
CPDF_StreamAcc::~CPDF_StreamAcc() {
if (m_bNewBuf)
@@ -28,7 +23,8 @@ void CPDF_StreamAcc::LoadAllData(bool bRawAccess,
if (!m_pStream)
return;
- if (m_pStream->IsMemoryBased() && (!m_pStream->HasFilter() || bRawAccess)) {
+ bool bProcessRawData = bRawAccess || !m_pStream->HasFilter();
+ if (bProcessRawData && m_pStream->IsMemoryBased()) {
m_dwSize = m_pStream->GetRawSize();
m_pData = m_pStream->GetRawData();
return;
@@ -38,14 +34,14 @@ void CPDF_StreamAcc::LoadAllData(bool bRawAccess,
return;
uint8_t* pSrcData;
- if (!m_pStream->IsMemoryBased()) {
+ if (m_pStream->IsMemoryBased()) {
+ pSrcData = m_pStream->GetRawData();
+ } else {
pSrcData = m_pSrcData = FX_Alloc(uint8_t, dwSrcSize);
if (!m_pStream->ReadRawData(0, pSrcData, dwSrcSize))
return;
- } else {
- pSrcData = m_pStream->GetRawData();
}
- if (!m_pStream->HasFilter() || bRawAccess) {
+ if (bProcessRawData) {
m_pData = pSrcData;
m_dwSize = dwSrcSize;
} else if (!PDF_DataDecode(pSrcData, dwSrcSize, m_pStream->GetDict(),
diff --git a/core/fpdfapi/parser/cpdf_stream_acc.h b/core/fpdfapi/parser/cpdf_stream_acc.h
index 6a18c43975..52ac7e2e05 100644
--- a/core/fpdfapi/parser/cpdf_stream_acc.h
+++ b/core/fpdfapi/parser/cpdf_stream_acc.h
@@ -44,13 +44,13 @@ class CPDF_StreamAcc : public Retainable {
private:
uint8_t* GetDataHelper() const;
- uint8_t* m_pData;
- uint32_t m_dwSize;
- bool m_bNewBuf;
+ uint8_t* m_pData = nullptr;
+ uint32_t m_dwSize = 0;
+ bool m_bNewBuf = false;
ByteString m_ImageDecoder;
- CPDF_Dictionary* m_pImageParam;
+ CPDF_Dictionary* m_pImageParam = nullptr;
UnownedPtr<const CPDF_Stream> const m_pStream;
- uint8_t* m_pSrcData;
+ uint8_t* m_pSrcData = nullptr;
};
#endif // CORE_FPDFAPI_PARSER_CPDF_STREAM_ACC_H_