Reviewers: Jakob,
Message:
Committed patchset #4 manually as r17711.
Description:
Fix overflow in TypedArray initialization function
BUG=chromium:319120
TEST=test/mjsunit/regress/regress-319120.js
[email protected]
Committed: http://code.google.com/p/v8/source/detail?r=17711
Please review this at https://codereview.chromium.org/61753013/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+3, -4 lines):
M src/runtime.cc
A + test/mjsunit/regress/regress-319120.js
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
9d317ca535f9630d97ccf08d920adee1e4284ca4..80b68279468fba09989f34c62ebf5a2e07175b07
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -956,12 +956,12 @@ RUNTIME_FUNCTION(MaybeObject*,
Runtime_TypedArrayInitializeFromArrayLike) {
Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer();
size_t length = NumberToSize(isolate, *length_obj);
- size_t byte_length = length * element_size;
- if (byte_length < length) { // Overflow
+ if (length > (kMaxInt / element_size)) {
return isolate->Throw(*isolate->factory()->
NewRangeError("invalid_array_buffer_length",
HandleVector<Object>(NULL, 0)));
}
+ size_t byte_length = length * element_size;
// NOTE: not initializing backing store.
// We assume that the caller of this function will initialize holder
Index: test/mjsunit/regress/regress-319120.js
diff --git a/test/mjsunit/regress/regress-2690.js
b/test/mjsunit/regress/regress-319120.js
similarity index 96%
copy from test/mjsunit/regress/regress-2690.js
copy to test/mjsunit/regress/regress-319120.js
index
5fe7dc42dc693cf7f0a3e9a2b13c0f7b306189e2..2899da25d9d9d82da0714270880cd203a9c5e96b
100644
--- a/test/mjsunit/regress/regress-2690.js
+++ b/test/mjsunit/regress/regress-319120.js
@@ -25,5 +25,4 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-assertTrue(/\1[a]/.test("\1a"));
-
+assertThrows('x = new Float64Array({length: 0x24924925})');
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.