summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/fpdf_parser_utility.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-07-25 20:57:25 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-25 20:57:25 +0000
commita35063cb627d611e77816216d0d8946794a98079 (patch)
tree458125d329ef663797001d78a9181429085ec9b5 /core/fpdfapi/parser/fpdf_parser_utility.cpp
parent35b51e95b9a4d0c064efd905e946a554d6f47890 (diff)
downloadpdfium-a35063cb627d611e77816216d0d8946794a98079.tar.xz
Change GetHeaderOffset() to return Optional<FX_FILESIZE>.
Remove |kInvalidHeaderOffset|. Change-Id: I5978e745e97aa4e13299dd21028721725ac0c996 Reviewed-on: https://pdfium-review.googlesource.com/38853 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Art Snake <art-snake@yandex-team.ru>
Diffstat (limited to 'core/fpdfapi/parser/fpdf_parser_utility.cpp')
-rw-r--r--core/fpdfapi/parser/fpdf_parser_utility.cpp13
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;