Bug 1385409 - Ignore ICO resource entries which contain little or no data. r=tnikkel
authorAndrew Osmond <aosmond@mozilla.com>
Tue, 01 Aug 2017 07:21:14 -0400
changeset 423323 7d01cd53da023a9080cb7a529a4190c51dd97d97
parent 423322 41faadcda947800651995e706f2f4e547832db4e
child 423324 407356a3597e87d9547ccab666b41a6e8780672a
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1385409
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1385409 - Ignore ICO resource entries which contain little or no data. r=tnikkel
image/decoders/nsICODecoder.cpp
--- a/image/decoders/nsICODecoder.cpp
+++ b/image/decoders/nsICODecoder.cpp
@@ -158,20 +158,25 @@ nsICODecoder::ReadDirEntry(const char* a
     e.mHeight      = aData[1];
     e.mColorCount  = aData[2];
     e.mReserved    = aData[3];
     e.mPlanes      = LittleEndian::readUint16(aData + 4);
     e.mBitCount    = LittleEndian::readUint16(aData + 6);
     e.mBytesInRes  = LittleEndian::readUint32(aData + 8);
     e.mImageOffset = offset;
     e.mSize        = IntSize(e.mWidth, e.mHeight);
-    if (e.mWidth == 0 || e.mHeight == 0) {
-      mUnsizedDirEntries.AppendElement(e);
-    } else {
-      mDirEntries.AppendElement(e);
+
+    // Only accept entries with sufficient resource data to actually contain
+    // some image data.
+    if (e.mBytesInRes > BITMAPINFOSIZE) {
+      if (e.mWidth == 0 || e.mHeight == 0) {
+        mUnsizedDirEntries.AppendElement(e);
+      } else {
+        mDirEntries.AppendElement(e);
+      }
     }
   }
 
   if (mCurrIcon == mNumIcons) {
     if (mUnsizedDirEntries.IsEmpty()) {
       return Transition::To(ICOState::FINISHED_DIR_ENTRY, 0);
     }
     return Transition::To(ICOState::ITERATE_UNSIZED_DIR_ENTRY, 0);