Index: test/cctest/test-strings.cc |
diff --git a/test/cctest/test-strings.cc b/test/cctest/test-strings.cc |
index d86886f9be3a14e48be06735ed931dd47f5c2d7c..e6b66656b8d1382355823b45d4fc87b5259d1371 100644 |
--- a/test/cctest/test-strings.cc |
+++ b/test/cctest/test-strings.cc |
@@ -672,3 +672,20 @@ TEST(RobustSubStringStub) { |
CompileRun("var slice = long.slice(1, 15);"); |
CheckException("%_SubString(slice, 0, 17);"); |
} |
+ |
+ |
+TEST(RegExpOverflow) { |
+ // Result string has the length 2^32, causing an 32-bit integer overflow. |
+ InitializeVM(); |
+ HandleScope scope; |
+ LocalContext context; |
+ v8::V8::IgnoreOutOfMemoryException(); |
+ v8::Local<v8::Value> result = CompileRun( |
+ "var a = 'a'; " |
+ "for (var i = 0; i < 16; i++) { " |
+ " a += a; " |
+ "} " |
+ "a.replace(/a/g, a); "); |
+ CHECK(result.IsEmpty()); |
+ CHECK(context->HasOutOfMemoryException()); |
+} |