Bug 961498: Prevent ICO decoder from exploding when faced with single-resource ICOs r=rnewman

This commit is contained in:
Chris Kitching 2014-01-19 19:25:47 +00:00
parent b43ef033c1
commit 37e4b74a7b
3 changed files with 4 additions and 5 deletions

View File

@ -5,7 +5,6 @@
package org.mozilla.gecko.favicons.decoders;
import android.graphics.Bitmap;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.gfx.BitmapUtils;
import java.util.Iterator;
@ -87,7 +86,7 @@ public class FaviconDecoder {
result = new LoadFaviconResult();
result.mOffset = offset;
result.mLength = length;
result.mHasMultipleBitmaps = false;
result.mIsICO = false;
// We assume here that decodeByteArray doesn't hold on to the entire supplied
// buffer -- worst case, each of our buffers will be twice the necessary size.

View File

@ -345,7 +345,7 @@ public class ICODecoder implements Iterable<Bitmap> {
result.mFaviconBytes = mDecodand;
result.mOffset = mOffset;
result.mLength = mLen;
result.mHasMultipleBitmaps = mIconDirectory.length > 1;
result.mIsICO = true;
return result;
}

View File

@ -25,7 +25,7 @@ public class LoadFaviconResult {
int mOffset;
int mLength;
boolean mHasMultipleBitmaps;
boolean mIsICO;
Iterator<Bitmap> mBitmapsDecoded;
public Iterator<Bitmap> getBitmaps() {
@ -49,7 +49,7 @@ public class LoadFaviconResult {
// For results containing a single image, we re-encode the result as a PNG in an effort to
// save space.
if (!mHasMultipleBitmaps) {
if (!mIsICO) {
Bitmap favicon = ((FaviconDecoder.SingleBitmapIterator) mBitmapsDecoded).peek();
byte[] data = null;
ByteArrayOutputStream stream = new ByteArrayOutputStream();