diff options
author | Artem Strygin <art-snake@yandex-team.ru> | 2017-08-01 14:49:46 +0300 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-01 12:01:58 +0000 |
commit | de7c9620c37486413e1f7db4567b4b0cea6a857f (patch) | |
tree | 24a98943484d79b4b3b5c370250db4bf7d3be395 /core/fpdfapi/parser | |
parent | ab3909796cf2e9fa192040bcd7cb9da7bb3328a5 (diff) | |
download | pdfium-de7c9620c37486413e1f7db4567b4b0cea6a857f.tar.xz |
Prevent use of null pFileRead in CPDF_DataAvail.chromium/3174
Change-Id: I52e668ca410a0c6b96a789ecc18c993152047ead
Reviewed-on: https://pdfium-review.googlesource.com/9550
Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser')
-rw-r--r-- | core/fpdfapi/parser/cpdf_data_avail.cpp | 38 |
1 files changed, 11 insertions, 27 deletions
diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp index bc81e991ca..88755a9eb7 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/parser/cpdf_data_avail.cpp @@ -57,17 +57,12 @@ class HintsAssigner { HintsAssigner(CPDF_ReadValidator* validator, CPDF_DataAvail::DownloadHints* hints) : validator_(validator) { - if (validator_) { - validator_->ResetErrors(); - validator_->SetDownloadHints(hints); - } + ASSERT(validator_); + validator_->ResetErrors(); + validator_->SetDownloadHints(hints); } - ~HintsAssigner() { - if (validator_) { - validator_->SetDownloadHints(nullptr); - } - } + ~HintsAssigner() { validator_->SetDownloadHints(nullptr); } private: CFX_UnownedPtr<CPDF_ReadValidator> validator_; @@ -83,16 +78,11 @@ CPDF_DataAvail::CPDF_DataAvail( FileAvail* pFileAvail, const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead, bool bSupportHintTable) - : m_pFileAvail(pFileAvail), - m_pFileRead( - pFileRead - ? pdfium::MakeRetain<CPDF_ReadValidator>(pFileRead, m_pFileAvail) - : nullptr) { + : m_pFileAvail(pFileAvail) { + ASSERT(pFileRead); + m_pFileRead = pdfium::MakeRetain<CPDF_ReadValidator>(pFileRead, m_pFileAvail); m_Pos = 0; - m_dwFileLen = 0; - if (m_pFileRead) { - m_dwFileLen = (uint32_t)m_pFileRead->GetSize(); - } + m_dwFileLen = m_pFileRead->GetSize(); m_dwCurrentOffset = 0; m_dwXRefOffset = 0; m_dwTrailerOffset = 0; @@ -237,13 +227,10 @@ bool CPDF_DataAvail::AreObjectsAvailable(std::vector<CPDF_Object*>& obj_array, CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsDocAvail( DownloadHints* pHints) { - const HintsAssigner hints_assigner(m_pFileRead.Get(), pHints); + if (!m_dwFileLen) + return DataError; - if (!m_dwFileLen && m_pFileRead) { - m_dwFileLen = (uint32_t)m_pFileRead->GetSize(); - if (!m_dwFileLen) - return DataError; - } + const HintsAssigner hints_assigner(m_pFileRead.Get(), pHints); while (!m_bDocAvail) { if (!CheckDocStatus(pHints)) @@ -744,9 +731,6 @@ CPDF_DataAvail::DocLinearizationStatus CPDF_DataAvail::IsLinearizedPDF() { if (!m_pFileAvail->IsDataAvail(0, kReqSize)) return LinearizationUnknown; - if (!m_pFileRead) - return NotLinearized; - FX_FILESIZE dwSize = m_pFileRead->GetSize(); if (dwSize < (FX_FILESIZE)kReqSize) return LinearizationUnknown; |