summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/parser/cpdf_stream_acc.cpp12
-rw-r--r--core/fpdfapi/parser/cpdf_stream_acc.h1
2 files changed, 5 insertions, 8 deletions
diff --git a/core/fpdfapi/parser/cpdf_stream_acc.cpp b/core/fpdfapi/parser/cpdf_stream_acc.cpp
index 78bcb57e0b..4614dae710 100644
--- a/core/fpdfapi/parser/cpdf_stream_acc.cpp
+++ b/core/fpdfapi/parser/cpdf_stream_acc.cpp
@@ -14,7 +14,6 @@ CPDF_StreamAcc::CPDF_StreamAcc(const CPDF_Stream* pStream)
CPDF_StreamAcc::~CPDF_StreamAcc() {
if (m_bNewBuf)
FX_Free(m_pData);
- FX_Free(m_pSrcData);
}
void CPDF_StreamAcc::LoadAllData(bool bRawAccess,
@@ -42,12 +41,12 @@ void CPDF_StreamAcc::LoadAllData(bool bRawAccess,
if (m_pStream->IsMemoryBased()) {
pSrcData = m_pStream->GetInMemoryRawData();
} else {
- pSrcData = m_pSrcData = FX_Alloc(uint8_t, dwSrcSize);
- if (!m_pStream->ReadRawData(0, pSrcData, dwSrcSize)) {
- FX_Free(pSrcData);
- pSrcData = m_pSrcData = nullptr;
+ std::unique_ptr<uint8_t, FxFreeDeleter> pTempSrcData(
+ FX_Alloc(uint8_t, dwSrcSize));
+ if (!m_pStream->ReadRawData(0, pTempSrcData.get(), dwSrcSize))
return;
- }
+
+ pSrcData = pTempSrcData.release();
}
if (bProcessRawData) {
m_pData = pSrcData;
@@ -60,7 +59,6 @@ void CPDF_StreamAcc::LoadAllData(bool bRawAccess,
}
if (pSrcData != m_pStream->GetInMemoryRawData() && pSrcData != m_pData)
FX_Free(pSrcData);
- m_pSrcData = nullptr;
m_bNewBuf = m_pData != m_pStream->GetInMemoryRawData();
}
diff --git a/core/fpdfapi/parser/cpdf_stream_acc.h b/core/fpdfapi/parser/cpdf_stream_acc.h
index ddbdc6ae0f..6ecfece5ab 100644
--- a/core/fpdfapi/parser/cpdf_stream_acc.h
+++ b/core/fpdfapi/parser/cpdf_stream_acc.h
@@ -53,7 +53,6 @@ class CPDF_StreamAcc final : public Retainable {
ByteString m_ImageDecoder;
UnownedPtr<const CPDF_Dictionary> m_pImageParam;
UnownedPtr<const CPDF_Stream> const m_pStream;
- uint8_t* m_pSrcData = nullptr;
};
#endif // CORE_FPDFAPI_PARSER_CPDF_STREAM_ACC_H_