Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Unified Diff: Source/platform/image-decoders/bmp/BMPImageReader.cpp

Issue 872683008: Small cleanup on BMPImageReader.cpp (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/platform/image-decoders/bmp/BMPImageReader.cpp
diff --git a/Source/platform/image-decoders/bmp/BMPImageReader.cpp b/Source/platform/image-decoders/bmp/BMPImageReader.cpp
index 32dc46d1baaf34f1750f1755dd30027909ab516f..def470893ca10879b67ab942b05041e4fe0fb6bb 100644
--- a/Source/platform/image-decoders/bmp/BMPImageReader.cpp
+++ b/Source/platform/image-decoders/bmp/BMPImageReader.cpp
@@ -96,7 +96,7 @@ bool BMPImageReader::decodeBMP(bool onlySize)
return false;
// Read and process info header.
- if ((m_decodedOffset < (m_headerOffset + m_infoHeader.biSize)) && !processInfoHeader())
+ if ((m_decodedOffset < sizeOfHeaderAndInfoHeader()) && !processInfoHeader())
return false;
// processInfoHeader() set the size, so if that's all we needed, we're done.
@@ -175,7 +175,8 @@ bool BMPImageReader::readInfoHeaderSize()
// Don't allow the header to overflow (which would be harmless here, but
// problematic or at least confusing in other places), or to overrun the
// image data.
- if (((m_headerOffset + m_infoHeader.biSize) < m_headerOffset) || (m_imgDataOffset && (m_imgDataOffset < (m_headerOffset + m_infoHeader.biSize))))
+ const size_t headerAndInfoHeaderSize = sizeOfHeaderAndInfoHeader();
Peter Kasting 2015/02/03 23:56:43 Nit: Call this |headerEnd|.
changseok 2015/02/04 04:10:32 Done.
+ if ((headerAndInfoHeaderSize < m_headerOffset) || (m_imgDataOffset && (m_imgDataOffset < headerAndInfoHeaderSize)))
return m_parent->setFailed();
// See if this is a header size we understand:
@@ -423,7 +424,9 @@ bool BMPImageReader::processBitmasks()
// Fail if we don't have enough file space for the bitmasks.
static const size_t SIZEOF_BITMASKS = 12;
Peter Kasting 2015/02/03 23:56:43 Nit: While here, change to: const size_t
changseok 2015/02/04 04:10:32 Done.
- if (((m_headerOffset + m_infoHeader.biSize + SIZEOF_BITMASKS) < (m_headerOffset + m_infoHeader.biSize)) || (m_imgDataOffset && (m_imgDataOffset < (m_headerOffset + m_infoHeader.biSize + SIZEOF_BITMASKS))))
+ const size_t headerAndInfoHeaderSize = sizeOfHeaderAndInfoHeader();
+ const size_t headerInfoHeaderAndBitmasksSize = headerAndInfoHeaderSize + SIZEOF_BITMASKS;
Peter Kasting 2015/02/03 23:56:43 Nit: Call these |headerEnd| and |bitmasksEnd|.
changseok 2015/02/04 04:10:32 Done.
+ if ((headerInfoHeaderAndBitmasksSize < headerAndInfoHeaderSize) || (m_imgDataOffset && (m_imgDataOffset < headerInfoHeaderAndBitmasksSize)))
return m_parent->setFailed();
// Read bitmasks.
@@ -530,9 +533,11 @@ bool BMPImageReader::processBitmasks()
bool BMPImageReader::processColorTable()
{
size_t tableSizeInBytes = m_infoHeader.biClrUsed * (m_isOS21x ? 3 : 4);
+ size_t headerAndInfoHeaderSize = sizeOfHeaderAndInfoHeader();
+ size_t headerInfoHeaderAndTableSize = headerAndInfoHeaderSize + tableSizeInBytes;
Peter Kasting 2015/02/03 23:56:43 Nit: Make all these const. Call the new variables
changseok 2015/02/04 04:10:32 Done.
// Fail if we don't have enough file space for the color table.
- if (((m_headerOffset + m_infoHeader.biSize + tableSizeInBytes) < (m_headerOffset + m_infoHeader.biSize)) || (m_imgDataOffset && (m_imgDataOffset < (m_headerOffset + m_infoHeader.biSize + tableSizeInBytes))))
+ if ((headerInfoHeaderAndTableSize < headerAndInfoHeaderSize) || (m_imgDataOffset && (m_imgDataOffset < headerInfoHeaderAndTableSize)))
return m_parent->setFailed();
// Read color table.

Powered by Google App Engine
This is Rietveld 408576698