mozilla/rhino — pull request #22 by msmhrt (2011-11-11 13:26:44+00:00)
Title: Fixed issue with repeated empty match causes infinite loop

This patch will pass the following mozilla JS tests.
ecma_3/RegExp/regress-367888.js
ecma_3/RegExp/regress-375642.js

with this patch:

js> /(|)??x/g.exec("y")
null
js>

without this patch:

js> /(|)??x/g.exec("y")
java.lang.OutOfMemoryError: Java heap space
at org.mozilla.javascript.regexp.NativeRegExp.pushProgState(NativeRegExp.java:1307)
at org.mozilla.javascript.regexp.NativeRegExp.executeREBytecode(NativeRegExp.java:1842)
at org.mozilla.javascript.regexp.NativeRegExp.matchRegExp(NativeRegExp.java:2249)
at org.mozilla.javascript.regexp.NativeRegExp.executeRegExp(NativeRegExp.java:2276)
at org.mozilla.javascript.regexp.NativeRegExp.execSub(NativeRegExp.java:279)
at org.mozilla.javascript.regexp.NativeRegExp.execIdCall(NativeRegExp.java:2549)
at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:129)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
at org.mozilla.javascript.gen._stdin__1._c_script_0(Unknown Source)
at org.mozilla.javascript.gen._stdin__1.call(Unknown Source)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3112)
at org.mozilla.javascript.gen._stdin__1.call(Unknown Source)
at org.mozilla.javascript.gen._stdin__1.exec(Unknown Source)
at org.mozilla.javascript.tools.shell.Main.evaluateScript(Main.java:650)
at org.mozilla.javascript.tools.shell.Main.processSource(Main.java:464)
at org.mozilla.javascript.tools.shell.Main.processFiles(Main.java:214)
at org.mozilla.javascript.tools.shell.Main$IProxy.run(Main.java:133)
at org.mozilla.javascript.Context.call(Context.java:521)
at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:536)
at org.mozilla.javascript.tools.shell.Main.exec(Main.java:197)
at org.mozilla.javascript.tools.shell.Main.main(Main.java:173)
js: exception from uncaught JavaScript throw: java.lang.OutOfMemoryError: Java heap space
js>