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

Side by Side Diff: test/cctest/test-strings.cc

Issue 10538012: Correctly check length when allocating string. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 2
3 // Check that we can traverse very deep stacks of ConsStrings using 3 // Check that we can traverse very deep stacks of ConsStrings using
4 // StringInputBuffer. Check that Get(int) works on very deep stacks 4 // StringInputBuffer. Check that Get(int) works on very deep stacks
5 // of ConsStrings. These operations may not be very fast, but they 5 // of ConsStrings. These operations may not be very fast, but they
6 // should be possible without getting errors due to too deep recursion. 6 // should be possible without getting errors due to too deep recursion.
7 7
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include "v8.h" 10 #include "v8.h"
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 // Ordinary HeapNumbers within bounds can be handled (in runtime). 665 // Ordinary HeapNumbers within bounds can be handled (in runtime).
666 result = CompileRun("%_SubString(long, Math.sqrt(4), 17.1);"); 666 result = CompileRun("%_SubString(long, Math.sqrt(4), 17.1);");
667 string = v8::Utils::OpenHandle(v8::String::Cast(*result)); 667 string = v8::Utils::OpenHandle(v8::String::Cast(*result));
668 CHECK_EQ("cdefghijklmnopq", *(string->ToCString())); 668 CHECK_EQ("cdefghijklmnopq", *(string->ToCString()));
669 669
670 // Test that out-of-bounds substring of a slice fails when the indices 670 // Test that out-of-bounds substring of a slice fails when the indices
671 // would have been valid for the underlying string. 671 // would have been valid for the underlying string.
672 CompileRun("var slice = long.slice(1, 15);"); 672 CompileRun("var slice = long.slice(1, 15);");
673 CheckException("%_SubString(slice, 0, 17);"); 673 CheckException("%_SubString(slice, 0, 17);");
674 } 674 }
675
676
677 TEST(RegExpOverflow) {
678 // Result string has the length 2^32, causing an 32-bit integer overflow.
679 InitializeVM();
680 HandleScope scope;
681 LocalContext context;
682 v8::V8::IgnoreOutOfMemoryException();
683 v8::Local<v8::Value> result = CompileRun(
684 "var a = 'a'; "
685 "for (var i = 0; i < 16; i++) { "
686 " a += a; "
687 "} "
688 "a.replace(/a/g, a); ");
689 CHECK(result.IsEmpty());
690 CHECK(context->HasOutOfMemoryException());
691 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698