summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/ArrayBufferView.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-05-24 08:28:08 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-05-24 08:28:08 +0000
commita4e969f4965059196ca948db781e52f7cfebf19e (patch)
tree6ca352808c8fdc52006a0f33f6ae3c593b23867d /Source/JavaScriptCore/runtime/ArrayBufferView.h
parent41386e9cb918eed93b3f13648cbef387e371e451 (diff)
downloadWebKitGtk-tarball-a4e969f4965059196ca948db781e52f7cfebf19e.tar.gz
webkitgtk-2.12.3webkitgtk-2.12.3
Diffstat (limited to 'Source/JavaScriptCore/runtime/ArrayBufferView.h')
-rw-r--r--Source/JavaScriptCore/runtime/ArrayBufferView.h22
1 files changed, 10 insertions, 12 deletions
diff --git a/Source/JavaScriptCore/runtime/ArrayBufferView.h b/Source/JavaScriptCore/runtime/ArrayBufferView.h
index 2b8f70d8b..3fc10b0dd 100644
--- a/Source/JavaScriptCore/runtime/ArrayBufferView.h
+++ b/Source/JavaScriptCore/runtime/ArrayBufferView.h
@@ -10,10 +10,10 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
@@ -77,22 +77,20 @@ public:
JS_EXPORT_PRIVATE virtual ~ArrayBufferView();
+ // Helper to verify byte offset is size aligned.
+ static bool verifyByteOffsetAlignment(unsigned byteOffset, size_t size)
+ {
+ return !(byteOffset & (size - 1));
+ }
+
// Helper to verify that a given sub-range of an ArrayBuffer is
// within range.
- // FIXME: This should distinguish between alignment errors and bounds errors.
- // https://bugs.webkit.org/show_bug.cgi?id=125391
- template <typename T>
- static bool verifySubRange(
- PassRefPtr<ArrayBuffer> buffer,
- unsigned byteOffset,
- unsigned numElements)
+ static bool verifySubRangeLength(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned numElements, size_t size)
{
unsigned byteLength = buffer->byteLength();
- if (sizeof(T) > 1 && byteOffset % sizeof(T))
- return false;
if (byteOffset > byteLength)
return false;
- unsigned remainingElements = (byteLength - byteOffset) / sizeof(T);
+ unsigned remainingElements = (byteLength - byteOffset) / size;
if (numElements > remainingElements)
return false;
return true;