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

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

Issue 1874373003: Replace ASSERTs with exit condition in StaticBitmapImage::draw (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/canvas/bug544329-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/graphics/StaticBitmapImage.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/StaticBitmapImage.cpp b/third_party/WebKit/Source/platform/graphics/StaticBitmapImage.cpp
index 809483742af938cc08451d9b0dcf77cab1d17804..87935c30df94f2cc18e01a2275215c6ac13ce349 100644
--- a/third_party/WebKit/Source/platform/graphics/StaticBitmapImage.cpp
+++ b/third_party/WebKit/Source/platform/graphics/StaticBitmapImage.cpp
@@ -40,13 +40,17 @@ bool StaticBitmapImage::currentFrameKnownToBeOpaque(MetadataMode)
void StaticBitmapImage::draw(SkCanvas* canvas, const SkPaint& paint, const FloatRect& dstRect,
const FloatRect& srcRect, RespectImageOrientationEnum, ImageClampingMode clampMode)
{
- ASSERT(dstRect.width() >= 0 && dstRect.height() >= 0);
- ASSERT(srcRect.width() >= 0 && srcRect.height() >= 0);
+ // Note: Sizes < 0 should never happen, except that the layout arithmetic
+ // may overflow in degenerate use cases, so we need to check for negatives,
+ // rather than only handle the isEmpty() case. See layout test
+ // fast/canvas/bug544329.html
+ if (dstRect.width() <= 0 || dstRect.height() <= 0 || srcRect.width() <= 0 || srcRect.height() <= 0)
+ return;
FloatRect adjustedSrcRect = srcRect;
adjustedSrcRect.intersect(FloatRect(0, 0, m_image->width(), m_image->height()));
- if (adjustedSrcRect.isEmpty() || dstRect.isEmpty())
+ if (adjustedSrcRect.isEmpty())
return; // Nothing to draw.
ASSERT(adjustedSrcRect.width() <= m_image->width() && adjustedSrcRect.height() <= m_image->height());
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/canvas/bug544329-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698