Bug 987340: Prevent favicon decoder choking on corrupt non-ICO bitmaps with valid magic numbers. r=rnewman

This commit is contained in:
Chris Kitching 2014-03-24 21:29:09 +00:00
parent 8bb1a4bbc3
commit dba6234894

View File

@ -93,9 +93,15 @@ public class FaviconDecoder {
result.length = length;
result.isICO = false;
Bitmap decodedImage = BitmapUtils.decodeByteArray(buffer, offset, length);
if (decodedImage == null) {
// What we got wasn't decodable after all. Probably corrupted image, or we got a muffled OOM.
return null;
}
// 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.
result.bitmapsDecoded = new SingleBitmapIterator(BitmapUtils.decodeByteArray(buffer, offset, length));
result.bitmapsDecoded = new SingleBitmapIterator(decodedImage);
result.faviconBytes = buffer;
return result;