diff options
-rw-r--r-- | BUILD.gn | 17 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp | 4 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h | 2 | ||||
-rw-r--r-- | core/fxcrt/fx_basic_gcc.cpp | 5 | ||||
-rw-r--r-- | core/fxcrt/fx_basic_gcc_unittest.cpp | 11 | ||||
-rw-r--r-- | core/fxge/ge/fx_ge_fontmap.cpp | 4 | ||||
-rw-r--r-- | fpdfsdk/fpdfformfill.cpp | 12 | ||||
-rw-r--r-- | fpdfsdk/fpdfview.cpp | 4 | ||||
-rw-r--r-- | pdfium.gyp | 2 |
9 files changed, 25 insertions, 36 deletions
@@ -43,24 +43,7 @@ config("pdfium_config") { if (is_win) { cflags += [ - "/wd4005", - "/wd4018", - "/wd4146", - "/wd4333", - "/wd4345", "/wd4267", - - # TODO(ochang): Investigate if this can be fixed properly. - "/wd4201", - - # TODO(thestig): Fix all instances, remove this, pdfium:29 - "/wd4245", - "/wd4310", - "/wd4389", - "/wd4701", - "/wd4702", - "/wd4706", - "/wd4800", ] } diff --git a/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp b/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp index a4b85a34fa..15f98b26b9 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp @@ -716,10 +716,10 @@ FX_BOOL CPDF_DataAvail::CheckFirstPage(IPDF_DataAvail::DownloadHints* pHints) { FX_BOOL CPDF_DataAvail::IsDataAvail(FX_FILESIZE offset, uint32_t size, IPDF_DataAvail::DownloadHints* pHints) { - if (offset > m_dwFileLen) + if (offset < 0 || offset > m_dwFileLen) return TRUE; - FX_SAFE_DWORD safeSize = pdfium::base::checked_cast<uint32_t>(offset); + FX_SAFE_FILESIZE safeSize = offset; safeSize += size; safeSize += 512; if (!safeSize.IsValid() || safeSize.ValueOrDie() > m_dwFileLen) diff --git a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h index 26b6a8d3df..04fe6f4fec 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h +++ b/core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h @@ -83,7 +83,7 @@ class CPDF_SyntaxParser { FX_FILESIZE m_Pos; int m_MetadataObjnum; IFX_FileRead* m_pFileAccess; - uint32_t m_HeaderOffset; + FX_FILESIZE m_HeaderOffset; FX_FILESIZE m_FileLen; uint8_t* m_pFileBuf; uint32_t m_BufSize; diff --git a/core/fxcrt/fx_basic_gcc.cpp b/core/fxcrt/fx_basic_gcc.cpp index 1b2f01ec89..c3afe1115b 100644 --- a/core/fxcrt/fx_basic_gcc.cpp +++ b/core/fxcrt/fx_basic_gcc.cpp @@ -39,7 +39,10 @@ IntType FXSYS_StrToInt(const CharType* str) { num = num * 10 + val; str++; } - return neg ? -num : num; + // When it is a negative value, -num should be returned. Since num may be of + // unsigned type, use ~num + 1 to avoid the warning of applying unary minus + // operator to unsigned type. + return neg ? ~num + 1 : num; } template <typename T, typename UT, typename STR_T> diff --git a/core/fxcrt/fx_basic_gcc_unittest.cpp b/core/fxcrt/fx_basic_gcc_unittest.cpp index c6913cfd82..73e7446de0 100644 --- a/core/fxcrt/fx_basic_gcc_unittest.cpp +++ b/core/fxcrt/fx_basic_gcc_unittest.cpp @@ -16,15 +16,16 @@ TEST(fxcrt, FXSYS_atoi) { EXPECT_EQ(2345, FXSYS_atoi("+2345")); // The max value. EXPECT_EQ(2147483647, FXSYS_atoi("2147483647")); - // The min value. - EXPECT_EQ(-2147483648, FXSYS_atoi("-2147483648")); + // The min value. Written in -1 format to avoid "unary minus operator applied + // to unsigned type" warning. + EXPECT_EQ(-2147483647 - 1, FXSYS_atoi("-2147483648")); // With invalid char. EXPECT_EQ(9, FXSYS_atoi("9x9")); // Out of range values. EXPECT_EQ(2147483647, FXSYS_atoi("2147483623423412348")); EXPECT_EQ(2147483647, FXSYS_atoi("2147483648")); - EXPECT_EQ(-2147483648, FXSYS_atoi("-2147483650")); + EXPECT_EQ(-2147483647 - 1, FXSYS_atoi("-2147483650")); } TEST(fxcrt, FXSYS_atoi64) { @@ -58,13 +59,13 @@ TEST(fxcrt, FXSYS_wtoi) { // The max value. EXPECT_EQ(2147483647, FXSYS_wtoi(L"2147483647")); // The min value. - EXPECT_EQ(-2147483648, FXSYS_wtoi(L"-2147483648")); + EXPECT_EQ(-2147483647 - 1, FXSYS_wtoi(L"-2147483648")); EXPECT_EQ(9, FXSYS_wtoi64(L"9x9")); // Out of range values. EXPECT_EQ(2147483647, FXSYS_wtoi(L"2147483623423412348")); EXPECT_EQ(2147483647, FXSYS_wtoi(L"2147483648")); - EXPECT_EQ(-2147483648, FXSYS_wtoi(L"-2147483652")); + EXPECT_EQ(-2147483647 - 1, FXSYS_wtoi(L"-2147483652")); } TEST(fxcrt, FXSYS_wtoi64) { diff --git a/core/fxge/ge/fx_ge_fontmap.cpp b/core/fxge/ge/fx_ge_fontmap.cpp index c6a6c5c003..c6b208c624 100644 --- a/core/fxge/ge/fx_ge_fontmap.cpp +++ b/core/fxge/ge/fx_ge_fontmap.cpp @@ -681,15 +681,17 @@ void CFX_FontMapper::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) { } m_pFontInfo = pFontInfo; } + static CFX_ByteString GetStringFromTable(const uint8_t* string_ptr, uint32_t string_ptr_length, uint16_t offset, uint16_t length) { - if (string_ptr_length < offset + length) { + if (string_ptr_length < static_cast<uint32_t>(offset + length)) { return CFX_ByteString(); } return CFX_ByteStringC(string_ptr + offset, length); } + CFX_ByteString GetNameFromTT(const uint8_t* name_table, uint32_t name_table_size, uint32_t name_id) { diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index 9230910a1f..ed6279a2c6 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -480,13 +480,13 @@ DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document, pXFAMenuHander->Copy((IXFA_Widget*)hWidget, wsCpText); CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); - int len = bsCpText.GetLength() / sizeof(unsigned short); + uint32_t len = bsCpText.GetLength() / sizeof(unsigned short); if (wsText == NULL) { *size = len; return; } - int real_size = len < *size ? len : *size; + uint32_t real_size = len < *size ? len : *size; if (real_size > 0) { FXSYS_memcpy((void*)wsText, bsCpText.GetBuffer(real_size * sizeof(unsigned short)), @@ -516,13 +516,13 @@ DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document, pXFAMenuHander->Cut((IXFA_Widget*)hWidget, wsCpText); CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); - int len = bsCpText.GetLength() / sizeof(unsigned short); + uint32_t len = bsCpText.GetLength() / sizeof(unsigned short); if (wsText == NULL) { *size = len; return; } - int real_size = len < *size ? len : *size; + uint32_t real_size = len < *size ? len : *size; if (real_size > 0) { FXSYS_memcpy((void*)wsText, bsCpText.GetBuffer(real_size * sizeof(unsigned short)), @@ -625,13 +625,13 @@ FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE sHandle, return FALSE; std::vector<CFX_ByteString>* sSuggestWords = FromFPDFStringHandle(sHandle); - int len = (*sSuggestWords)[index].GetLength(); + uint32_t len = (*sSuggestWords)[index].GetLength(); if (!bsText) { *size = len; return TRUE; } - int real_size = len < *size ? len : *size; + uint32_t real_size = len < *size ? len : *size; if (real_size > 0) FXSYS_memcpy((void*)bsText, (const FX_CHAR*)(*sSuggestWords)[index], real_size); diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index 9183b4073b..3a3449745c 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -391,7 +391,7 @@ class CMemFile final : public IFX_FileRead { FX_SAFE_FILESIZE newPos = pdfium::base::checked_cast<FX_FILESIZE, size_t>(size); newPos += offset; - if (!newPos.IsValid() || newPos.ValueOrDie() > (uint32_t)m_size) { + if (!newPos.IsValid() || newPos.ValueOrDie() > m_size) { return FALSE; } FXSYS_memcpy(buffer, m_pBuf + offset, size); @@ -1155,7 +1155,7 @@ DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, CFX_WideString wsName = PDF_DecodeText(bsName); CFX_ByteString utf16Name = wsName.UTF16LE_Encode(); - unsigned int len = utf16Name.GetLength(); + int len = utf16Name.GetLength(); if (!buffer) { *buflen = len; } else if (*buflen >= len) { diff --git a/pdfium.gyp b/pdfium.gyp index 63d0c03404..ed6003ed81 100644 --- a/pdfium.gyp +++ b/pdfium.gyp @@ -93,7 +93,7 @@ }], ], 'msvs_disabled_warnings': [ - 4018, 4146, 4333, 4345, 4267, + 4267, ], 'variables': { 'clang_warning_flags': [ |