diff options
author | dsinclair <dsinclair@chromium.org> | 2016-04-06 12:06:35 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-06 12:06:35 -0700 |
commit | 4e20094dbb2ea942734b8986fa9a60d2f3ccbb1b (patch) | |
tree | ebb642f2387b2a5ab4335944c549eccd1d142124 /core/fpdfapi | |
parent | 6fe7d2174a47107578da912299c93b4dfb9f2add (diff) | |
download | pdfium-4e20094dbb2ea942734b8986fa9a60d2f3ccbb1b.tar.xz |
Rename FX_SAFE_DWORD to FX_SAFE_UINT32
We removed the FX_DWORD typedef in favour of uint32_t. This CL cleans up the
FX_SAFE_DWORD naming to match.
BUG=pdfium:81, pdfium:470
Review URL: https://codereview.chromium.org/1861403002
Diffstat (limited to 'core/fpdfapi')
-rw-r--r-- | core/fpdfapi/fpdf_page/fpdf_page_func.cpp | 4 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp | 23 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_parser.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_render/fpdf_render_image.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp | 24 |
7 files changed, 32 insertions, 31 deletions
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_func.cpp b/core/fpdfapi/fpdf_page/fpdf_page_func.cpp index ebd6811da8..b00ab73af1 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_func.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_func.cpp @@ -541,7 +541,7 @@ FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) { m_pSampleStream = new CPDF_StreamAcc; m_pSampleStream->LoadAllData(pStream, FALSE); m_pEncodeInfo = FX_Alloc(SampleEncodeInfo, m_nInputs); - FX_SAFE_DWORD nTotalSampleBits = 1; + FX_SAFE_UINT32 nTotalSampleBits = 1; for (uint32_t i = 0; i < m_nInputs; i++) { m_pEncodeInfo[i].sizes = pSize ? pSize->GetIntegerAt(i) : 0; if (!pSize && i == 0) @@ -560,7 +560,7 @@ FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) { } nTotalSampleBits *= m_nBitsPerSample; nTotalSampleBits *= m_nOutputs; - FX_SAFE_DWORD nTotalSampleBytes = nTotalSampleBits; + FX_SAFE_UINT32 nTotalSampleBytes = nTotalSampleBits; nTotalSampleBytes += 7; nTotalSampleBytes /= 8; if (!nTotalSampleBytes.IsValid() || nTotalSampleBytes.ValueOrDie() == 0 || diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index a3c88c00df..183573aaa3 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -797,7 +797,7 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) { if (m_InternalStage == STAGE_GETCONTENT) { if (m_CurrentOffset == m_nStreams) { if (!m_StreamArray.empty()) { - FX_SAFE_DWORD safeSize = 0; + FX_SAFE_UINT32 safeSize = 0; for (const auto& stream : m_StreamArray) { safeSize += stream->GetSize(); safeSize += 1; diff --git a/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp b/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp index 15f98b26b9..68f8b88557 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp @@ -1507,7 +1507,7 @@ IPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedData( return DataAvailable; if (!m_bMainXRefLoadTried) { - FX_SAFE_DWORD data_size = m_dwFileLen; + FX_SAFE_UINT32 data_size = m_dwFileLen; data_size -= m_dwLastXRefOffset; if (!data_size.IsValid()) return DataError; diff --git a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp index 18687e5fb7..3e08ead9ff 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp @@ -16,7 +16,7 @@ namespace { bool CanReadFromBitStream(const CFX_BitStream* hStream, - const FX_SAFE_DWORD& num_bits) { + const FX_SAFE_UINT32& num_bits) { return num_bits.IsValid() && hStream->BitsRemaining() >= num_bits.ValueOrDie(); } @@ -60,7 +60,7 @@ FX_BOOL CPDF_HintTables::ReadPageHintTable(CFX_BitStream* hStream) { // Item 2: The location of the first page's page object. uint32_t dwFirstObjLoc = hStream->GetBits(32); if (dwFirstObjLoc > static_cast<uint32_t>(nStreamOffset)) { - FX_SAFE_DWORD safeLoc = pdfium::base::checked_cast<uint32_t>(nStreamLen); + FX_SAFE_UINT32 safeLoc = pdfium::base::checked_cast<uint32_t>(nStreamLen); safeLoc += dwFirstObjLoc; if (!safeLoc.IsValid()) return FALSE; @@ -107,13 +107,13 @@ FX_BOOL CPDF_HintTables::ReadPageHintTable(CFX_BitStream* hStream) { if (nPages < 1) return FALSE; - FX_SAFE_DWORD required_bits = dwDeltaObjectsBits; + FX_SAFE_UINT32 required_bits = dwDeltaObjectsBits; required_bits *= pdfium::base::checked_cast<uint32_t>(nPages); if (!CanReadFromBitStream(hStream, required_bits)) return FALSE; for (int i = 0; i < nPages; ++i) { - FX_SAFE_DWORD safeDeltaObj = hStream->GetBits(dwDeltaObjectsBits); + FX_SAFE_UINT32 safeDeltaObj = hStream->GetBits(dwDeltaObjectsBits); safeDeltaObj += dwObjLeastNum; if (!safeDeltaObj.IsValid()) return FALSE; @@ -128,7 +128,7 @@ FX_BOOL CPDF_HintTables::ReadPageHintTable(CFX_BitStream* hStream) { CFX_ArrayTemplate<uint32_t> dwPageLenArray; for (int i = 0; i < nPages; ++i) { - FX_SAFE_DWORD safePageLen = hStream->GetBits(dwDeltaPageLenBits); + FX_SAFE_UINT32 safePageLen = hStream->GetBits(dwDeltaPageLenBits); safePageLen += dwPageLeastLen; if (!safePageLen.IsValid()) return FALSE; @@ -191,7 +191,7 @@ FX_BOOL CPDF_HintTables::ReadPageHintTable(CFX_BitStream* hStream) { hStream->ByteAlign(); for (int i = 0; i < nPages; i++) { - FX_SAFE_DWORD safeSize = m_dwNSharedObjsArray[i]; + FX_SAFE_UINT32 safeSize = m_dwNSharedObjsArray[i]; safeSize *= dwSharedNumeratorBits; if (!CanReadFromBitStream(hStream, safeSize)) return FALSE; @@ -200,7 +200,8 @@ FX_BOOL CPDF_HintTables::ReadPageHintTable(CFX_BitStream* hStream) { } hStream->ByteAlign(); - FX_SAFE_DWORD safeTotalPageLen = pdfium::base::checked_cast<uint32_t>(nPages); + FX_SAFE_UINT32 safeTotalPageLen = + pdfium::base::checked_cast<uint32_t>(nPages); safeTotalPageLen *= dwDeltaPageLenBits; if (!CanReadFromBitStream(hStream, safeTotalPageLen)) return FALSE; @@ -220,7 +221,7 @@ FX_BOOL CPDF_HintTables::ReadSharedObjHintTable(CFX_BitStream* hStream, if (nStreamOffset < 0 || nStreamLen < 1) return FALSE; - FX_SAFE_DWORD bit_offset = offset; + FX_SAFE_UINT32 bit_offset = offset; bit_offset *= 8; if (!bit_offset.IsValid() || hStream->GetPos() > bit_offset.ValueOrDie()) return FALSE; @@ -263,14 +264,14 @@ FX_BOOL CPDF_HintTables::ReadSharedObjHintTable(CFX_BitStream* hStream, uint32_t dwPrevObjLen = 0; uint32_t dwCurObjLen = 0; - FX_SAFE_DWORD required_bits = dwSharedObjTotal; + FX_SAFE_UINT32 required_bits = dwSharedObjTotal; required_bits *= dwDeltaGroupLen; if (!CanReadFromBitStream(hStream, required_bits)) return FALSE; for (uint32_t i = 0; i < dwSharedObjTotal; ++i) { dwPrevObjLen = dwCurObjLen; - FX_SAFE_DWORD safeObjLen = hStream->GetBits(dwDeltaGroupLen); + FX_SAFE_UINT32 safeObjLen = hStream->GetBits(dwDeltaGroupLen); safeObjLen += dwGroupLeastLen; if (!safeObjLen.IsValid()) return FALSE; @@ -281,7 +282,7 @@ FX_BOOL CPDF_HintTables::ReadSharedObjHintTable(CFX_BitStream* hStream, if (i == 0) m_szSharedObjOffsetArray.push_back(m_szFirstPageObjOffset); } else { - FX_SAFE_DWORD safeObjNum = dwFirstSharedObjNum; + FX_SAFE_UINT32 safeObjNum = dwFirstSharedObjNum; safeObjNum += i - m_nFirstPageSharedObjs; if (!safeObjNum.IsValid()) return FALSE; diff --git a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp index 73ca71ef1a..15af1ca5c7 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp @@ -1012,7 +1012,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) { } CFX_ArrayTemplate<uint32_t> WidthArray; - FX_SAFE_DWORD dwAccWidth = 0; + FX_SAFE_UINT32 dwAccWidth = 0; for (uint32_t i = 0; i < pArray->GetCount(); i++) { WidthArray.Add(pArray->GetIntegerAt(i)); dwAccWidth += WidthArray[i]; @@ -1039,7 +1039,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) { pdfium::base::checked_cast<uint32_t, int32_t>(startnum); uint32_t count = pdfium::base::checked_cast<uint32_t, int32_t>(arrIndex[i].second); - FX_SAFE_DWORD dwCaculatedSize = segindex; + FX_SAFE_UINT32 dwCaculatedSize = segindex; dwCaculatedSize += count; dwCaculatedSize *= totalWidth; if (!dwCaculatedSize.IsValid() || @@ -1048,7 +1048,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) { } const uint8_t* segstart = pData + segindex * totalWidth; - FX_SAFE_DWORD dwMaxObjNum = startnum; + FX_SAFE_UINT32 dwMaxObjNum = startnum; dwMaxObjNum += count; uint32_t dwV5Size = m_ObjectInfo.empty() ? 0 : GetLastObjNum() + 1; if (!dwMaxObjNum.IsValid() || dwMaxObjNum.ValueOrDie() > dwV5Size) diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp index 167570ba92..16c55c57af 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp @@ -931,7 +931,7 @@ CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict, } CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps); FX_FLOAT* pFloats = float_array; - FX_SAFE_DWORD num_floats = comps; + FX_SAFE_UINT32 num_floats = comps; num_floats *= sizeof(FX_FLOAT); if (!num_floats.IsValid()) { return NULL; diff --git a/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp index 61e47036fa..db1b8ccd71 100644 --- a/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp +++ b/core/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp @@ -38,8 +38,8 @@ unsigned int GetBits8(const uint8_t* pData, uint64_t bitpos, size_t nbits) { return (byte >> (8 - nbits - (bitpos % 8))) & ((1 << nbits) - 1); } -FX_SAFE_DWORD CalculatePitch8(uint32_t bpc, uint32_t components, int width) { - FX_SAFE_DWORD pitch = bpc; +FX_SAFE_UINT32 CalculatePitch8(uint32_t bpc, uint32_t components, int width) { + FX_SAFE_UINT32 pitch = bpc; pitch *= components; pitch *= width; pitch += 7; @@ -47,8 +47,8 @@ FX_SAFE_DWORD CalculatePitch8(uint32_t bpc, uint32_t components, int width) { return pitch; } -FX_SAFE_DWORD CalculatePitch32(int bpp, int width) { - FX_SAFE_DWORD pitch = bpp; +FX_SAFE_UINT32 CalculatePitch32(int bpp, int width) { + FX_SAFE_UINT32 pitch = bpp; pitch *= width; pitch += 31; pitch /= 32; // quantized to number of 32-bit words. @@ -177,7 +177,7 @@ FX_BOOL CPDF_DIBSource::Load(CPDF_Document* pDoc, if (m_bDoBpcCheck && (m_bpc == 0 || m_nComponents == 0)) { return FALSE; } - FX_SAFE_DWORD src_size = + FX_SAFE_UINT32 src_size = CalculatePitch8(m_bpc, m_nComponents, m_Width) * m_Height; if (!src_size.IsValid()) { return FALSE; @@ -202,7 +202,7 @@ FX_BOOL CPDF_DIBSource::Load(CPDF_Document* pDoc, } else { m_bpp = 24; } - FX_SAFE_DWORD pitch = CalculatePitch32(m_bpp, m_Width); + FX_SAFE_UINT32 pitch = CalculatePitch32(m_bpp, m_Width); if (!pitch.IsValid()) { return FALSE; } @@ -246,7 +246,7 @@ int CPDF_DIBSource::ContinueToLoadMask() { if (!m_bpc || !m_nComponents) { return 0; } - FX_SAFE_DWORD pitch = CalculatePitch32(m_bpp, m_Width); + FX_SAFE_UINT32 pitch = CalculatePitch32(m_bpp, m_Width); if (!pitch.IsValid()) { return 0; } @@ -299,7 +299,7 @@ int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc, if (m_bDoBpcCheck && (m_bpc == 0 || m_nComponents == 0)) { return 0; } - FX_SAFE_DWORD src_size = + FX_SAFE_UINT32 src_size = CalculatePitch8(m_bpc, m_nComponents, m_Width) * m_Height; if (!src_size.IsValid()) { return 0; @@ -611,12 +611,12 @@ int CPDF_DIBSource::CreateDecoder() { if (!m_pDecoder) return 0; - FX_SAFE_DWORD requested_pitch = + FX_SAFE_UINT32 requested_pitch = CalculatePitch8(m_bpc, m_nComponents, m_Width); if (!requested_pitch.IsValid()) { return 0; } - FX_SAFE_DWORD provided_pitch = CalculatePitch8( + FX_SAFE_UINT32 provided_pitch = CalculatePitch8( m_pDecoder->GetBPC(), m_pDecoder->CountComps(), m_pDecoder->GetWidth()); if (!provided_pitch.IsValid()) { return 0; @@ -1030,7 +1030,7 @@ const uint8_t* CPDF_DIBSource::GetScanline(int line) const { if (m_bpc == 0) { return nullptr; } - FX_SAFE_DWORD src_pitch = CalculatePitch8(m_bpc, m_nComponents, m_Width); + FX_SAFE_UINT32 src_pitch = CalculatePitch8(m_bpc, m_nComponents, m_Width); if (!src_pitch.IsValid()) return nullptr; uint32_t src_pitch_value = src_pitch.ValueOrDie(); @@ -1176,7 +1176,7 @@ void CPDF_DIBSource::DownSampleScanline(int line, } uint32_t src_width = m_Width; - FX_SAFE_DWORD pitch = CalculatePitch8(m_bpc, m_nComponents, m_Width); + FX_SAFE_UINT32 pitch = CalculatePitch8(m_bpc, m_nComponents, m_Width); if (!pitch.IsValid()) return; |