summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_parser
diff options
context:
space:
mode:
authorweili <weili@chromium.org>2016-06-03 14:06:36 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-03 14:06:36 -0700
commit8d4e0d47f4cd0325be84ebf310fd8de989761939 (patch)
tree7ce5f43aef4c0091852612bbe53ecbfe9e51a7a1 /core/fpdfapi/fpdf_parser
parentb71dc76df4a1eb04f89a64cd542a1d585df3251e (diff)
downloadpdfium-8d4e0d47f4cd0325be84ebf310fd8de989761939.tar.xz
Fix more bugs found by /analyze tool
Three more bugs are discovered: -- potientially used freed pointer; -- potientially used uninitialized variable; -- Used '&&' instead of bitwise operator '&' BUG=chromium:613623, chromium:427616 Review-Url: https://codereview.chromium.org/2040503002
Diffstat (limited to 'core/fpdfapi/fpdf_parser')
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_stream_acc.cpp41
1 files changed, 13 insertions, 28 deletions
diff --git a/core/fpdfapi/fpdf_parser/cpdf_stream_acc.cpp b/core/fpdfapi/fpdf_parser/cpdf_stream_acc.cpp
index afac3ebf6f..81144919fe 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_stream_acc.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_stream_acc.cpp
@@ -42,55 +42,40 @@ void CPDF_StreamAcc::LoadAllData(const CPDF_Stream* pStream,
} else {
pSrcData = pStream->GetRawData();
}
- uint8_t* pDecryptedData = pSrcData;
- uint32_t dwDecryptedSize = dwSrcSize;
if (!pStream->GetDict()->KeyExist("Filter") || bRawAccess) {
- m_pData = pDecryptedData;
- m_dwSize = dwDecryptedSize;
+ m_pData = pSrcData;
+ m_dwSize = dwSrcSize;
} else {
- FX_BOOL bRet = PDF_DataDecode(
- pDecryptedData, dwDecryptedSize, m_pStream->GetDict(), m_pData,
- m_dwSize, m_ImageDecoder, m_pImageParam, estimated_size, bImageAcc);
+ FX_BOOL bRet = PDF_DataDecode(pSrcData, dwSrcSize, m_pStream->GetDict(),
+ m_pData, m_dwSize, m_ImageDecoder,
+ m_pImageParam, estimated_size, bImageAcc);
if (!bRet) {
- m_pData = pDecryptedData;
- m_dwSize = dwDecryptedSize;
+ m_pData = pSrcData;
+ m_dwSize = dwSrcSize;
}
}
- if (pSrcData != pStream->GetRawData() && pSrcData != m_pData) {
+ if (pSrcData != pStream->GetRawData() && pSrcData != m_pData)
FX_Free(pSrcData);
- }
- if (pDecryptedData != pSrcData && pDecryptedData != m_pData) {
- FX_Free(pDecryptedData);
- }
m_pSrcData = nullptr;
m_bNewBuf = m_pData != pStream->GetRawData();
}
CPDF_StreamAcc::~CPDF_StreamAcc() {
- if (m_bNewBuf) {
+ if (m_bNewBuf)
FX_Free(m_pData);
- }
FX_Free(m_pSrcData);
}
const uint8_t* CPDF_StreamAcc::GetData() const {
- if (m_bNewBuf) {
+ if (m_bNewBuf)
return m_pData;
- }
- if (!m_pStream) {
- return nullptr;
- }
- return m_pStream->GetRawData();
+ return m_pStream ? m_pStream->GetRawData() : nullptr;
}
uint32_t CPDF_StreamAcc::GetSize() const {
- if (m_bNewBuf) {
+ if (m_bNewBuf)
return m_dwSize;
- }
- if (!m_pStream) {
- return 0;
- }
- return m_pStream->GetRawSize();
+ return m_pStream ? m_pStream->GetRawSize() : 0;
}
uint8_t* CPDF_StreamAcc::DetachData() {