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

Unified Diff: src/typedarray.js

Issue 18313007: Change DataView accessors behavior for insufficient args. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed bug Created 7 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
« no previous file with comments | « no previous file | test/mjsunit/harmony/dataview-accessors.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/typedarray.js
diff --git a/src/typedarray.js b/src/typedarray.js
index 57d0c60f9ba00dfd4a00e1649d872057d76269f8..891b4d7d272e82547a02955c09cfced80d90f7a5 100644
--- a/src/typedarray.js
+++ b/src/typedarray.js
@@ -259,6 +259,9 @@ function DataViewGetInt8(offset, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.getInt8', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
return %DataViewGetInt8(this,
ToPositiveDataViewOffset(offset),
!!little_endian);
@@ -269,6 +272,9 @@ function DataViewSetInt8(offset, value, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.setInt8', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
%DataViewSetInt8(this,
ToPositiveDataViewOffset(offset),
TO_NUMBER_INLINE(value),
@@ -280,6 +286,9 @@ function DataViewGetUint8(offset, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.getUint8', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
return %DataViewGetUint8(this,
ToPositiveDataViewOffset(offset),
!!little_endian);
@@ -290,6 +299,9 @@ function DataViewSetUint8(offset, value, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.setUint8', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
%DataViewSetUint8(this,
ToPositiveDataViewOffset(offset),
TO_NUMBER_INLINE(value),
@@ -301,6 +313,9 @@ function DataViewGetInt16(offset, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.getInt16', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
return %DataViewGetInt16(this,
ToPositiveDataViewOffset(offset),
!!little_endian);
@@ -311,6 +326,9 @@ function DataViewSetInt16(offset, value, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.setInt16', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
%DataViewSetInt16(this,
ToPositiveDataViewOffset(offset),
TO_NUMBER_INLINE(value),
@@ -322,6 +340,9 @@ function DataViewGetUint16(offset, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.getUint16', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
return %DataViewGetUint16(this,
ToPositiveDataViewOffset(offset),
!!little_endian);
@@ -332,6 +353,9 @@ function DataViewSetUint16(offset, value, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.setUint16', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
%DataViewSetUint16(this,
ToPositiveDataViewOffset(offset),
TO_NUMBER_INLINE(value),
@@ -343,6 +367,9 @@ function DataViewGetInt32(offset, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.getInt32', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
return %DataViewGetInt32(this,
ToPositiveDataViewOffset(offset),
!!little_endian);
@@ -353,6 +380,9 @@ function DataViewSetInt32(offset, value, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.setInt32', this]);
}
+ if (%_ArgumentsLength() < 2) {
+ throw MakeTypeError('invalid_argument');
+ }
%DataViewSetInt32(this,
ToPositiveDataViewOffset(offset),
TO_NUMBER_INLINE(value),
@@ -364,6 +394,9 @@ function DataViewGetUint32(offset, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.getUint32', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
return %DataViewGetUint32(this,
ToPositiveDataViewOffset(offset),
!!little_endian);
@@ -374,6 +407,9 @@ function DataViewSetUint32(offset, value, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.setUint32', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
%DataViewSetUint32(this,
ToPositiveDataViewOffset(offset),
TO_NUMBER_INLINE(value),
@@ -385,6 +421,9 @@ function DataViewGetFloat32(offset, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.getFloat32', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
return %DataViewGetFloat32(this,
ToPositiveDataViewOffset(offset),
!!little_endian);
@@ -395,6 +434,9 @@ function DataViewSetFloat32(offset, value, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.setFloat32', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
%DataViewSetFloat32(this,
ToPositiveDataViewOffset(offset),
TO_NUMBER_INLINE(value),
@@ -406,9 +448,8 @@ function DataViewGetFloat64(offset, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.getFloat64', this]);
}
- offset = TO_INTEGER(offset);
- if (offset < 0) {
- throw MakeRangeError("invalid_data_view_accessor_offset");
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
}
return %DataViewGetFloat64(this,
ToPositiveDataViewOffset(offset),
@@ -420,9 +461,8 @@ function DataViewSetFloat64(offset, value, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.setFloat64', this]);
}
- offset = TO_INTEGER(offset);
- if (offset < 0) {
- throw MakeRangeError("invalid_data_view_accessor_offset");
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
}
%DataViewSetFloat64(this,
ToPositiveDataViewOffset(offset),
« no previous file with comments | « no previous file | test/mjsunit/harmony/dataview-accessors.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698