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

Unified Diff: third_party/WebKit/Source/core/html/ImageData.cpp

Issue 1814563002: wtf/CheckedArithmetic.h delegates to base/numerics/safe_math.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/core/html/ImageData.cpp
diff --git a/third_party/WebKit/Source/core/html/ImageData.cpp b/third_party/WebKit/Source/core/html/ImageData.cpp
index 5909815ff778fe4b73edb20e0e8d706676850b60..82a6375ddad68a9294df9dfd9d5a03fced87ba23 100644
--- a/third_party/WebKit/Source/core/html/ImageData.cpp
+++ b/third_party/WebKit/Source/core/html/ImageData.cpp
@@ -39,14 +39,13 @@ namespace blink {
ImageData* ImageData::create(const IntSize& size)
{
- Checked<int, RecordOverflow> dataSize = 4;
+ WTF::CheckedNumeric<int> dataSize = 4;
dataSize *= size.width();
dataSize *= size.height();
- if (dataSize.hasOverflowed() || dataSize.unsafeGet() < 0)
+ if (!dataSize.IsValid() || dataSize.ValueOrDie() < 0)
return nullptr;
- RefPtr<DOMUint8ClampedArray> byteArray =
- DOMUint8ClampedArray::createOrNull(dataSize.unsafeGet());
+ RefPtr<DOMUint8ClampedArray> byteArray = DOMUint8ClampedArray::createOrNull(dataSize.ValueOrDie());
if (!byteArray)
return nullptr;
@@ -55,14 +54,14 @@ ImageData* ImageData::create(const IntSize& size)
ImageData* ImageData::create(const IntSize& size, PassRefPtr<DOMUint8ClampedArray> byteArray)
{
- Checked<int, RecordOverflow> dataSize = 4;
+ WTF::CheckedNumeric<int> dataSize = 4;
dataSize *= size.width();
dataSize *= size.height();
- if (dataSize.hasOverflowed())
+ if (!dataSize.IsValid())
return nullptr;
- if (dataSize.unsafeGet() < 0
- || static_cast<unsigned>(dataSize.unsafeGet()) > byteArray->length())
+ if (dataSize.ValueOrDie() < 0
+ || static_cast<unsigned>(dataSize.ValueOrDie()) > byteArray->length())
return nullptr;
return new ImageData(size, byteArray);
@@ -75,18 +74,17 @@ ImageData* ImageData::create(unsigned width, unsigned height, ExceptionState& ex
return nullptr;
}
- Checked<unsigned, RecordOverflow> dataSize = 4;
+ WTF::CheckedNumeric<unsigned> dataSize = 4;
dataSize *= width;
dataSize *= height;
- if (dataSize.hasOverflowed()
+ if (!dataSize.IsValid()
|| static_cast<int>(width) < 0
|| static_cast<int>(height) < 0) {
exceptionState.throwDOMException(IndexSizeError, "The requested image size exceeds the supported range.");
return nullptr;
}
- RefPtr<DOMUint8ClampedArray> byteArray =
- DOMUint8ClampedArray::createOrNull(dataSize.unsafeGet());
+ RefPtr<DOMUint8ClampedArray> byteArray = DOMUint8ClampedArray::createOrNull(dataSize.ValueOrDie());
if (!byteArray) {
exceptionState.throwDOMException(V8GeneralError, "Out of memory at ImageData creation");
return nullptr;

Powered by Google App Engine
This is Rietveld 408576698