From a12159b17085796e2b72d2b49e850092e0b4e8b7 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 15 Mar 2017 13:26:37 -0700 Subject: Refactor some CPDF_ColorSpace code. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I1e30d68dae3bf70cf3c426f6126d593b7f1c3ba4 Reviewed-on: https://pdfium-review.googlesource.com/2991 Commit-Queue: Lei Zhang Reviewed-by: Nicolás Peña --- core/fpdfapi/parser/cpdf_security_handler.cpp | 2 +- core/fpdfapi/parser/fpdf_parser_decode.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'core/fpdfapi/parser') diff --git a/core/fpdfapi/parser/cpdf_security_handler.cpp b/core/fpdfapi/parser/cpdf_security_handler.cpp index 61834fca13..cfc51350d9 100644 --- a/core/fpdfapi/parser/cpdf_security_handler.cpp +++ b/core/fpdfapi/parser/cpdf_security_handler.cpp @@ -52,7 +52,7 @@ void CalcEncryptKey(CPDF_Dictionary* pEncrypt, } if (!bIgnoreMeta && revision >= 3 && !pEncrypt->GetIntegerFor("EncryptMetadata", 1)) { - uint32_t tag = (uint32_t)-1; + uint32_t tag = 0xFFFFFFFF; CRYPT_MD5Update(&md5, (uint8_t*)&tag, 4); } uint8_t digest[16]; diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp index 98bb4eedf5..af1f452afd 100644 --- a/core/fpdfapi/parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp @@ -101,9 +101,9 @@ uint32_t A85Decode(const uint8_t* src_buf, // Count the space needed to contain non-zero characters. The encoding ratio // of Ascii85 is 4:5. uint32_t space_for_non_zeroes = (pos - zcount) / 5 * 4 + 4; - if (zcount > (UINT_MAX - space_for_non_zeroes) / 4) { - return (uint32_t)-1; - } + if (zcount > (UINT_MAX - space_for_non_zeroes) / 4) + return 0xFFFFFFFF; + dest_buf = FX_Alloc(uint8_t, zcount * 4 + space_for_non_zeroes); size_t state = 0; uint32_t res = 0; @@ -315,7 +315,7 @@ uint32_t FPDFAPI_FlateOrLZWDecode(bool bLZW, BitsPerComponent = pParams->GetIntegerFor("BitsPerComponent", 8); Columns = pParams->GetIntegerFor("Columns", 1); if (!CheckFlateDecodeParams(Colors, BitsPerComponent, Columns)) - return (uint32_t)-1; + return 0xFFFFFFFF; } return CPDF_ModuleMgr::Get()->GetFlateModule()->FlateOrLZWDecode( bLZW, src_buf, src_size, bEarlyChange, predictor, Colors, @@ -358,7 +358,7 @@ bool PDF_DataDecode(const uint8_t* src_buf, CFX_ByteString decoder = DecoderArray[i].first; CPDF_Dictionary* pParam = ToDictionary(DecoderArray[i].second); uint8_t* new_buf = nullptr; - uint32_t new_size = (uint32_t)-1; + uint32_t new_size = 0xFFFFFFFF; int offset = -1; if (decoder == "FlateDecode" || decoder == "Fl") { if (bImageAcc && i == nSize - 1) { -- cgit v1.2.3