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

Unified Diff: third_party/WebKit/Source/platform/graphics/BitmapImage.cpp

Issue 2173873003: Cancel image loads if decoding failed (attempt #2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix UAF Created 4 years, 5 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: third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp b/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
index c361c5b307450c79d0bae24ff1cb89d6563ec282..8788a62448b541c25446cbdcf3b0bc34e93d1bd0 100644
--- a/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
+++ b/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp
@@ -189,21 +189,24 @@ bool BitmapImage::getHotSpot(IntPoint& hotSpot) const
return m_source.getHotSpot(hotSpot);
}
-bool BitmapImage::setData(PassRefPtr<SharedBuffer> data, bool allDataReceived)
+Image::SizeAvailability BitmapImage::setData(PassRefPtr<SharedBuffer> data, bool allDataReceived)
{
if (!data.get())
- return true;
+ return SizeAvailable;
int length = data->size();
if (!length)
- return true;
+ return SizeAvailable;
- m_source.setData(*data, allDataReceived);
+ // If ImageSource::setData() returns Invalid, we know that this is a decode error.
+ // Report size available so that it gets registered as such in ImageResource.
+ if (m_source.setData(*data, allDataReceived) == ImageDecoder::SniffResult::Invalid)
+ return SizeAvailable;
return dataChanged(allDataReceived);
}
-bool BitmapImage::dataChanged(bool allDataReceived)
+Image::SizeAvailability BitmapImage::dataChanged(bool allDataReceived)
{
TRACE_EVENT0("blink", "BitmapImage::dataChanged");
@@ -239,7 +242,7 @@ bool BitmapImage::dataChanged(bool allDataReceived)
m_allDataReceived = allDataReceived;
m_haveFrameCount = false;
- return isSizeAvailable();
+ return isSizeAvailable() ? SizeAvailable : SizeUnavailable;
}
bool BitmapImage::hasColorProfile() const

Powered by Google App Engine
This is Rietveld 408576698