зеркало из https://github.com/mozilla/gecko-dev.git
Bug 961498: Prevent ICO decoder from exploding when faced with single-resource ICOs r=rnewman
This commit is contained in:
Родитель
5015c16747
Коммит
b2dd2df186
|
@ -5,7 +5,6 @@
|
||||||
package org.mozilla.gecko.favicons.decoders;
|
package org.mozilla.gecko.favicons.decoders;
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import org.mozilla.gecko.GeckoAppShell;
|
|
||||||
import org.mozilla.gecko.gfx.BitmapUtils;
|
import org.mozilla.gecko.gfx.BitmapUtils;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -87,7 +86,7 @@ public class FaviconDecoder {
|
||||||
result = new LoadFaviconResult();
|
result = new LoadFaviconResult();
|
||||||
result.mOffset = offset;
|
result.mOffset = offset;
|
||||||
result.mLength = length;
|
result.mLength = length;
|
||||||
result.mHasMultipleBitmaps = false;
|
result.mIsICO = false;
|
||||||
|
|
||||||
// We assume here that decodeByteArray doesn't hold on to the entire supplied
|
// 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.
|
// buffer -- worst case, each of our buffers will be twice the necessary size.
|
||||||
|
|
|
@ -345,7 +345,7 @@ public class ICODecoder implements Iterable<Bitmap> {
|
||||||
result.mFaviconBytes = mDecodand;
|
result.mFaviconBytes = mDecodand;
|
||||||
result.mOffset = mOffset;
|
result.mOffset = mOffset;
|
||||||
result.mLength = mLen;
|
result.mLength = mLen;
|
||||||
result.mHasMultipleBitmaps = mIconDirectory.length > 1;
|
result.mIsICO = true;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class LoadFaviconResult {
|
||||||
int mOffset;
|
int mOffset;
|
||||||
int mLength;
|
int mLength;
|
||||||
|
|
||||||
boolean mHasMultipleBitmaps;
|
boolean mIsICO;
|
||||||
Iterator<Bitmap> mBitmapsDecoded;
|
Iterator<Bitmap> mBitmapsDecoded;
|
||||||
|
|
||||||
public Iterator<Bitmap> getBitmaps() {
|
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
|
// For results containing a single image, we re-encode the result as a PNG in an effort to
|
||||||
// save space.
|
// save space.
|
||||||
if (!mHasMultipleBitmaps) {
|
if (!mIsICO) {
|
||||||
Bitmap favicon = ((FaviconDecoder.SingleBitmapIterator) mBitmapsDecoded).peek();
|
Bitmap favicon = ((FaviconDecoder.SingleBitmapIterator) mBitmapsDecoded).peek();
|
||||||
byte[] data = null;
|
byte[] data = null;
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче