diff options
Diffstat (limited to 'core/fpdfapi')
-rw-r--r-- | core/fpdfapi/page/cpdf_streamparser.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_crypto_handler.cpp | 8 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_crypto_handler.h | 4 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_data_avail.cpp | 27 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_data_avail.h | 2 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_stream_acc.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_syntax_parser.cpp | 10 | ||||
-rw-r--r-- | core/fpdfapi/parser/fpdf_parser_decode.cpp | 16 | ||||
-rw-r--r-- | core/fpdfapi/parser/fpdf_parser_decode.h | 2 |
9 files changed, 37 insertions, 36 deletions
diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp index 3c4e534116..e0c6e25aef 100644 --- a/core/fpdfapi/page/cpdf_streamparser.cpp +++ b/core/fpdfapi/page/cpdf_streamparser.cpp @@ -62,7 +62,7 @@ uint32_t PDF_DecodeInlineStream(const uint8_t* src_buf, uint32_t limit, int width, int height, - CFX_ByteString& decoder, + const CFX_ByteString& decoder, CPDF_Dictionary* pParam, uint8_t*& dest_buf, uint32_t& dest_size) { diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.cpp b/core/fpdfapi/parser/cpdf_crypto_handler.cpp index 4fc7b3039b..ea09601b30 100644 --- a/core/fpdfapi/parser/cpdf_crypto_handler.cpp +++ b/core/fpdfapi/parser/cpdf_crypto_handler.cpp @@ -227,14 +227,14 @@ bool CPDF_CryptoHandler::CryptFinish(void* context, return true; } -void CPDF_CryptoHandler::Decrypt(uint32_t objnum, - uint32_t gennum, - CFX_ByteString& str) { +CFX_ByteString CPDF_CryptoHandler::Decrypt(uint32_t objnum, + uint32_t gennum, + const CFX_ByteString& str) { CFX_BinaryBuf dest_buf; void* context = DecryptStart(objnum, gennum); DecryptStream(context, str.raw_str(), str.GetLength(), dest_buf); DecryptFinish(context, dest_buf); - str = CFX_ByteString(dest_buf.GetBuffer(), dest_buf.GetSize()); + return CFX_ByteString(dest_buf.GetBuffer(), dest_buf.GetSize()); } void* CPDF_CryptoHandler::DecryptStart(uint32_t objnum, uint32_t gennum) { diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.h b/core/fpdfapi/parser/cpdf_crypto_handler.h index 63a2590950..1e3890a55b 100644 --- a/core/fpdfapi/parser/cpdf_crypto_handler.h +++ b/core/fpdfapi/parser/cpdf_crypto_handler.h @@ -23,7 +23,9 @@ class CPDF_CryptoHandler { CPDF_SecurityHandler* pSecurityHandler); uint32_t DecryptGetSize(uint32_t src_size); void* DecryptStart(uint32_t objnum, uint32_t gennum); - void Decrypt(uint32_t objnum, uint32_t gennum, CFX_ByteString& str); + CFX_ByteString Decrypt(uint32_t objnum, + uint32_t gennum, + const CFX_ByteString& str); bool DecryptStream(void* context, const uint8_t* src_buf, uint32_t src_size, diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp index 5a2db8861c..aa0b4fdad6 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/parser/cpdf_data_avail.cpp @@ -837,7 +837,7 @@ void CPDF_DataAvail::SetStartOffset(FX_FILESIZE dwOffset) { m_Pos = dwOffset; } -bool CPDF_DataAvail::GetNextToken(CFX_ByteString& token) { +bool CPDF_DataAvail::GetNextToken(CFX_ByteString* token) { uint8_t ch; if (!GetNextChar(ch)) return false; @@ -870,11 +870,9 @@ bool CPDF_DataAvail::GetNextToken(CFX_ByteString& token) { if (!PDFCharIsOther(ch) && !PDFCharIsNumeric(ch)) { m_Pos--; - CFX_ByteString ret(buffer, index); - token = ret; + *token = CFX_ByteString(buffer, index); return true; } - if (index < sizeof(buffer)) buffer[index++] = ch; } @@ -895,9 +893,7 @@ bool CPDF_DataAvail::GetNextToken(CFX_ByteString& token) { else m_Pos--; } - - CFX_ByteString ret(buffer, index); - token = ret; + *token = CFX_ByteString(buffer, index); return true; } @@ -914,7 +910,7 @@ bool CPDF_DataAvail::GetNextToken(CFX_ByteString& token) { } } - token = CFX_ByteString(buffer, index); + *token = CFX_ByteString(buffer, index); return true; } @@ -948,8 +944,9 @@ bool CPDF_DataAvail::CheckCrossRefItem(DownloadHints* pHints) { int32_t iSize = 0; CFX_ByteString token; while (1) { - if (!GetNextToken(token)) { - iSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); + if (!GetNextToken(&token)) { + iSize = static_cast<int32_t>( + m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); pHints->AddSegment(m_Pos, iSize); return false; } @@ -983,8 +980,9 @@ bool CPDF_DataAvail::CheckAllCrossRefStream(DownloadHints* pHints) { bool CPDF_DataAvail::CheckCrossRef(DownloadHints* pHints) { int32_t iSize = 0; CFX_ByteString token; - if (!GetNextToken(token)) { - iSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); + if (!GetNextToken(&token)) { + iSize = static_cast<int32_t>(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos + : 512); pHints->AddSegment(m_Pos, iSize); return false; } @@ -995,8 +993,9 @@ bool CPDF_DataAvail::CheckCrossRef(DownloadHints* pHints) { } while (1) { - if (!GetNextToken(token)) { - iSize = (int32_t)(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); + if (!GetNextToken(&token)) { + iSize = static_cast<int32_t>( + m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos : 512); pHints->AddSegment(m_Pos, iSize); m_docStatus = PDF_DATAAVAIL_CROSSREF_ITEM; return false; diff --git a/core/fpdfapi/parser/cpdf_data_avail.h b/core/fpdfapi/parser/cpdf_data_avail.h index 65638cff0b..62c5d49c9d 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.h +++ b/core/fpdfapi/parser/cpdf_data_avail.h @@ -156,7 +156,7 @@ class CPDF_DataAvail final { int32_t CheckCrossRefStream(DownloadHints* pHints, FX_FILESIZE& xref_offset); bool IsLinearizedFile(uint8_t* pData, uint32_t dwLen); void SetStartOffset(FX_FILESIZE dwOffset); - bool GetNextToken(CFX_ByteString& token); + bool GetNextToken(CFX_ByteString* token); bool GetNextChar(uint8_t& ch); std::unique_ptr<CPDF_Object> ParseIndirectObjectAt( FX_FILESIZE pos, diff --git a/core/fpdfapi/parser/cpdf_stream_acc.cpp b/core/fpdfapi/parser/cpdf_stream_acc.cpp index 77ef2ff2bc..fe333e4d2b 100644 --- a/core/fpdfapi/parser/cpdf_stream_acc.cpp +++ b/core/fpdfapi/parser/cpdf_stream_acc.cpp @@ -43,7 +43,7 @@ void CPDF_StreamAcc::LoadAllData(bool bRawAccess, m_pData = pSrcData; m_dwSize = dwSrcSize; } else if (!PDF_DataDecode(pSrcData, dwSrcSize, m_pStream->GetDict(), m_pData, - m_dwSize, m_ImageDecoder, m_pImageParam, + m_dwSize, &m_ImageDecoder, m_pImageParam, estimated_size, bImageAcc)) { m_pData = pSrcData; m_dwSize = dwSrcSize; diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp index 73bf56d206..1c84b859db 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp @@ -405,13 +405,13 @@ std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetObject( if (word == "(") { CFX_ByteString str = ReadString(); if (m_pCryptoHandler && bDecrypt) - m_pCryptoHandler->Decrypt(objnum, gennum, str); + str = m_pCryptoHandler->Decrypt(objnum, gennum, str); return pdfium::MakeUnique<CPDF_String>(m_pPool, str, false); } if (word == "<") { CFX_ByteString str = ReadHexString(); if (m_pCryptoHandler && bDecrypt) - m_pCryptoHandler->Decrypt(objnum, gennum, str); + str = m_pCryptoHandler->Decrypt(objnum, gennum, str); return pdfium::MakeUnique<CPDF_String>(m_pPool, str, true); } if (word == "[") { @@ -526,17 +526,17 @@ std::unique_ptr<CPDF_Object> CPDF_SyntaxParser::GetObjectForStrict( if (word == "(") { CFX_ByteString str = ReadString(); if (m_pCryptoHandler) - m_pCryptoHandler->Decrypt(objnum, gennum, str); + str = m_pCryptoHandler->Decrypt(objnum, gennum, str); return pdfium::MakeUnique<CPDF_String>(m_pPool, str, false); } if (word == "<") { CFX_ByteString str = ReadHexString(); if (m_pCryptoHandler) - m_pCryptoHandler->Decrypt(objnum, gennum, str); + str = m_pCryptoHandler->Decrypt(objnum, gennum, str); return pdfium::MakeUnique<CPDF_String>(m_pPool, str, true); } if (word == "[") { - std::unique_ptr<CPDF_Array> pArray = pdfium::MakeUnique<CPDF_Array>(); + auto pArray = pdfium::MakeUnique<CPDF_Array>(); while (std::unique_ptr<CPDF_Object> pObj = GetObject(pObjList, objnum, gennum, true)) { pArray->Add(std::move(pObj)); diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp index a1698aedde..cc8b507025 100644 --- a/core/fpdfapi/parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp @@ -327,7 +327,7 @@ bool PDF_DataDecode(const uint8_t* src_buf, const CPDF_Dictionary* pDict, uint8_t*& dest_buf, uint32_t& dest_size, - CFX_ByteString& ImageEncoding, + CFX_ByteString* ImageEncoding, CPDF_Dictionary*& pImageParms, uint32_t last_estimated_size, bool bImageAcc) { @@ -362,8 +362,8 @@ bool PDF_DataDecode(const uint8_t* src_buf, int offset = -1; if (decoder == "FlateDecode" || decoder == "Fl") { if (bImageAcc && i == nSize - 1) { - ImageEncoding = "FlateDecode"; - dest_buf = (uint8_t*)last_buf; + *ImageEncoding = "FlateDecode"; + dest_buf = last_buf; dest_size = last_size; pImageParms = pParam; return true; @@ -379,8 +379,8 @@ bool PDF_DataDecode(const uint8_t* src_buf, offset = HexDecode(last_buf, last_size, new_buf, new_size); } else if (decoder == "RunLengthDecode" || decoder == "RL") { if (bImageAcc && i == nSize - 1) { - ImageEncoding = "RunLengthDecode"; - dest_buf = (uint8_t*)last_buf; + *ImageEncoding = "RunLengthDecode"; + dest_buf = last_buf; dest_size = last_size; pImageParms = pParam; return true; @@ -395,9 +395,9 @@ bool PDF_DataDecode(const uint8_t* src_buf, } else if (decoder == "CCF") { decoder = "CCITTFaxDecode"; } - ImageEncoding = decoder; + *ImageEncoding = decoder; pImageParms = pParam; - dest_buf = (uint8_t*)last_buf; + dest_buf = last_buf; dest_size = last_size; if (CPDF_Array* pDecoders = pDecoder->AsArray()) pDecoders->RemoveAt(i + 1, pDecoders->GetCount() - i - 1); @@ -413,7 +413,7 @@ bool PDF_DataDecode(const uint8_t* src_buf, last_buf = new_buf; last_size = new_size; } - ImageEncoding = ""; + *ImageEncoding = ""; pImageParms = nullptr; dest_buf = last_buf; dest_size = last_size; diff --git a/core/fpdfapi/parser/fpdf_parser_decode.h b/core/fpdfapi/parser/fpdf_parser_decode.h index 0c74e41058..955a8cfb32 100644 --- a/core/fpdfapi/parser/fpdf_parser_decode.h +++ b/core/fpdfapi/parser/fpdf_parser_decode.h @@ -87,7 +87,7 @@ bool PDF_DataDecode(const uint8_t* src_buf, const CPDF_Dictionary* pDict, uint8_t*& dest_buf, uint32_t& dest_size, - CFX_ByteString& ImageEncoding, + CFX_ByteString* ImageEncoding, CPDF_Dictionary*& pImageParms, uint32_t estimated_size, bool bImageAcc); |