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

Unified Diff: test/mjsunit/regexp.js

Issue 21078: RegExp parser: Fixed unchecked numeric overflow bug. (Closed)
Patch Set: Created 11 years, 10 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
Index: test/mjsunit/regexp.js
diff --git a/test/mjsunit/regexp.js b/test/mjsunit/regexp.js
index a54961aea41fd398c050073902a30c513bd01484..e562df09023f7212a61f0d1acbc76e772347fe2d 100644
--- a/test/mjsunit/regexp.js
+++ b/test/mjsunit/regexp.js
@@ -304,11 +304,44 @@ for (var i = 0; i < 128; i++) {
assertFalse(/f(o)$\1/.test('foo'), "backref detects at_end");
// Check decimal escapes doesn't overflow.
-
+// (Note: \214 is interpreted as octal).
assertEquals(/\2147483648/.exec("\x8c7483648"),
["\x8c7483648"],
"Overflow decimal escape");
+
+// Check numbers in quantifiers doesn't overflow and doesn't throw on
+// too large numbers.
+assertFalse(/a{111111111111111111111111111111111111111111111}/.test('b'),
+ "overlarge1");
+assertFalse(/a{999999999999999999999999999999999999999999999}/.test('b'),
+ "overlarge2");
+assertFalse(/a{1,111111111111111111111111111111111111111111111}/.test('b'),
+ "overlarge3");
+assertFalse(/a{1,999999999999999999999999999999999999999999999}/.test('b'),
+ "overlarge4");
+assertFalse(/a{2147483648}/.test('b'),
+ "overlarge5");
+assertFalse(/a{21474836471}/.test('b'),
+ "overlarge6");
+assertFalse(/a{1,2147483648}/.test('b'),
+ "overlarge7");
+assertFalse(/a{1,21474836471}/.test('b'),
+ "overlarge8");
+assertFalse(/a{2147483648,2147483648}/.test('b'),
+ "overlarge9");
+assertFalse(/a{21474836471,21474836471}/.test('b'),
+ "overlarge10");
+assertFalse(/a{2147483647}/.test('b'),
+ "overlarge11");
+assertFalse(/a{1,2147483647}/.test('b'),
+ "overlarge12");
+assertTrue(/a{1,2147483647}/.test('a'),
+ "overlarge13");
+assertFalse(/a{2147483647,2147483647}/.test('a'),
+ "overlarge14");
+
+
// Check that we don't read past the end of the string.
assertFalse(/f/.test('b'));
assertFalse(/[abc]f/.test('x'));
« src/parser.cc ('K') | « src/parser.cc ('k') | test/mjsunit/regexp-pcre.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698