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

Unified Diff: Source/WebCore/bindings/js/JSArrayBufferViewHelper.h

Issue 7523024: Merge 91803 - Float32Array(ArrayBuffer, index, length) constructor working incorrectly. (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/835/
Patch Set: Created 9 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: Source/WebCore/bindings/js/JSArrayBufferViewHelper.h
===================================================================
--- Source/WebCore/bindings/js/JSArrayBufferViewHelper.h (revision 91888)
+++ Source/WebCore/bindings/js/JSArrayBufferViewHelper.h (working copy)
@@ -93,11 +93,16 @@
return 0;
unsigned offset = (exec->argumentCount() > 1) ? exec->argument(1).toUInt32(exec) : 0;
- if ((buffer->byteLength() - offset) % sizeof(T))
- throwError(exec, createRangeError(exec, "ArrayBuffer length minus the byteOffset is not a multiple of the element size."));
- unsigned int length = (buffer->byteLength() - offset) / sizeof(T);
+ unsigned int length = 0;
if (exec->argumentCount() > 2)
length = exec->argument(2).toUInt32(exec);
+ else {
+ if ((buffer->byteLength() - offset) % sizeof(T)) {
+ throwError(exec, createRangeError(exec, "ArrayBuffer length minus the byteOffset is not a multiple of the element size."));
+ return 0;
+ }
+ length = (buffer->byteLength() - offset) / sizeof(T);
+ }
RefPtr<C> array = C::create(buffer, offset, length);
if (!array)
setDOMException(exec, INDEX_SIZE_ERR);

Powered by Google App Engine
This is Rietveld 408576698