diff options
Diffstat (limited to 'core/fpdfapi/parser/fpdf_parser_utility.cpp')
-rw-r--r-- | core/fpdfapi/parser/fpdf_parser_utility.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/fpdfapi/parser/fpdf_parser_utility.cpp b/core/fpdfapi/parser/fpdf_parser_utility.cpp index 3c99415d21..83c967d8c2 100644 --- a/core/fpdfapi/parser/fpdf_parser_utility.cpp +++ b/core/fpdfapi/parser/fpdf_parser_utility.cpp @@ -71,17 +71,18 @@ const char PDF_CharType[256] = { 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'W'}; -int32_t GetHeaderOffset(const RetainPtr<IFX_SeekableReadStream>& pFile) { - const size_t kBufSize = 4; +Optional<FX_FILESIZE> GetHeaderOffset( + const RetainPtr<IFX_SeekableReadStream>& pFile) { + static constexpr size_t kBufSize = 4; uint8_t buf[kBufSize]; - for (int32_t offset = 0; offset <= 1024; ++offset) { + for (FX_FILESIZE offset = 0; offset <= 1024; ++offset) { if (!pFile->ReadBlock(buf, offset, kBufSize)) - return kInvalidHeaderOffset; + return {}; if (memcmp(buf, "%PDF", 4) == 0) return offset; } - return kInvalidHeaderOffset; + return {}; } int32_t GetDirectInteger(const CPDF_Dictionary* pDict, const ByteString& key) { @@ -114,7 +115,7 @@ ByteString PDF_NameDecode(const ByteStringView& bstr) { } ByteString PDF_NameEncode(const ByteString& orig) { - uint8_t* src_buf = (uint8_t*)orig.c_str(); + const uint8_t* src_buf = reinterpret_cast<const uint8_t*>(orig.c_str()); int src_len = orig.GetLength(); int dest_len = 0; int i; |