diff options
author | thestig <thestig@chromium.org> | 2016-07-29 06:15:39 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-29 06:15:39 -0700 |
commit | 823df2adff3c9a87a61de33eeefab5669000e429 (patch) | |
tree | 8ca8404db5cb4eb14d33afd24d90c81433717db4 /core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | |
parent | dbfc3522a6ee24d17f2c50a5dcc465db52a280ee (diff) | |
download | pdfium-823df2adff3c9a87a61de33eeefab5669000e429.tar.xz |
Cleanup CPDF_DocPageData release methods and callers.
Review-Url: https://codereview.chromium.org/2194853002
Diffstat (limited to 'core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp')
-rw-r--r-- | core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index 42adb84638..2639d7aa5c 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -160,36 +160,36 @@ CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc, uint32_t bpc = pDict->GetIntegerBy("BitsPerComponent"); uint32_t nComponents = 1; CPDF_ColorSpace* pCS = pDoc->LoadColorSpace(pCSObj); - if (!pCS) { - nComponents = 3; - } else { + if (pCS) { nComponents = pCS->CountComponents(); pDoc->GetPageData()->ReleaseColorSpace(pCSObj); + } else { + nComponents = 3; } uint32_t pitch = width; - if (bpc && pitch > INT_MAX / bpc) { + if (bpc && pitch > INT_MAX / bpc) return nullptr; - } + pitch *= bpc; - if (nComponents && pitch > INT_MAX / nComponents) { + if (nComponents && pitch > INT_MAX / nComponents) return nullptr; - } + pitch *= nComponents; - if (pitch > INT_MAX - 7) { + if (pitch > INT_MAX - 7) return nullptr; - } + pitch += 7; pitch /= 8; OrigSize = pitch; } else { - if (width > INT_MAX - 7) { + if (width > INT_MAX - 7) return nullptr; - } + OrigSize = ((width + 7) / 8); } - if (height && OrigSize > INT_MAX / height) { + if (height && OrigSize > INT_MAX / height) return nullptr; - } + OrigSize *= height; uint8_t* pData = nullptr; uint32_t dwStreamSize; |