Index: src/arraybuffer.js |
diff --git a/src/arraybuffer.js b/src/arraybuffer.js |
index 2b0c3dd85b1107bc2f5a98d355a24ad7a974e9fe..06cc653b0969ea82e5077222baeeb7008cb0b58f 100644 |
--- a/src/arraybuffer.js |
+++ b/src/arraybuffer.js |
@@ -31,12 +31,12 @@ var $ArrayBuffer = global.ArrayBuffer; |
// ------------------------------------------------------------------- |
-function ArrayBufferConstructor(byteLength) { // length = 1 |
+function ArrayBufferConstructor(length) { // length = 1 |
if (%_IsConstructCall()) { |
- var l = TO_POSITIVE_INTEGER(byteLength); |
- %ArrayBufferInitialize(this, l); |
+ var byteLength = ToPositiveInteger(length, 'invalid_array_buffer_length'); |
+ %ArrayBufferInitialize(this, byteLength); |
} else { |
- return new $ArrayBuffer(byteLength); |
+ return new $ArrayBuffer(length); |
} |
} |
@@ -70,6 +70,9 @@ function ArrayBufferSlice(start, end) { |
fin = MathMin(relativeEnd, this.byteLength); |
} |
+ if (fin < first) { |
+ fin = first; |
+ } |
var newLen = fin - first; |
// TODO(dslomov): implement inheritance |
var result = new $ArrayBuffer(newLen); |