diff options
Diffstat (limited to 'core/fpdfapi/fpdf_parser')
-rw-r--r-- | core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp index a4cc85ae7d..caffb6861b 100644 --- a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp +++ b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp @@ -69,20 +69,14 @@ const char PDF_CharType[256] = { 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'W'}; int32_t GetHeaderOffset(IFX_FileRead* pFile) { - // TODO(dsinclair): This is a complicated way of saying %PDF, simplify? - const FX_DWORD tag = FXDWORD_FROM_LSBFIRST(0x46445025); - const size_t kBufSize = 4; uint8_t buf[kBufSize]; - int32_t offset = 0; - while (offset <= 1024) { + for (int32_t offset = 0; offset <= 1024; ++offset) { if (!pFile->ReadBlock(buf, offset, kBufSize)) return -1; - if (*(FX_DWORD*)buf == tag) + if (memcmp(buf, "%PDF", 4) == 0) return offset; - - ++offset; } return -1; } |