Closed
Bug 217379
Opened 21 years ago
Closed 21 years ago
rhino NullPointerException with String.prototype.replace(re, func)
Categories
(Rhino Graveyard :: Compiler, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
1.5R5
People
(Reporter: mda, Assigned: norrisboyd)
Details
Attachments
(1 file)
1.24 KB,
patch
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.5a) Gecko/20030728 Mozilla Firebird/0.6.1
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.5a) Gecko/20030728 Mozilla Firebird/0.6.1
In Rhino 1_5R5pre,
var re = /(\s)?/g;
var s = "foo";
s.replace(re, function() {return ''});
results in the stack trace below.
it works in SpiderMonkey.
of course the code above is stupid, but it is a simplified version of
non-stupid but more complicated code that revealed the bug to me.
-mda
Exception in thread "main" java.lang.NullPointerException
at org.mozilla.javascript.regexp.ReplaceData.findReplen(RegExpImpl.java:486)
at org.mozilla.javascript.regexp.ReplaceData.doGlobal(RegExpImpl.java:361)
at org.mozilla.javascript.regexp.RegExpImpl.matchOrReplace(RegExpImpl.java:186)
at org.mozilla.javascript.regexp.RegExpImpl.replace(RegExpImpl.java:105)
at org.mozilla.javascript.NativeString.execMethod(NativeString.java:244)
at org.mozilla.javascript.IdFunction.call(IdFunction.java:78)
at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1195)
at
org.mozilla.javascript.gen.c2.call(/Users/mda/Sites/burstproject/****/quicktest.js:3)
at
org.mozilla.javascript.gen.c2.exec(/Users/mda/Sites/burstproject/****/quicktest.js)
at org.mozilla.javascript.Context.evaluateReader(Context.java:806)
at org.mozilla.javascript.tools.shell.Main.evaluateReader(Main.java:363)
at org.mozilla.javascript.tools.shell.Main.processFileSecure(Main.java:354)
at org.mozilla.javascript.tools.shell.Main.processFile(Main.java:291)
at org.mozilla.javascript.tools.shell.Main.processSource(Main.java:283)
at org.mozilla.javascript.tools.shell.Main.exec(Main.java:103)
at org.mozilla.javascript.tools.shell.Main.main(Main.java:76)
Reproducible: Always
Steps to Reproduce:
1.
2.
3.
Comment 1•21 years ago
|
||
The code in RegExpImpl.findReplen did not take into account that a particular
parenthesis pair can be null if it is not captured. The patch fixes that to
send undefined to the replace function for that case.
Comment 2•21 years ago
|
||
I committed the fix.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Summary: rhino NullPointerException with String.prototype.replace(re, func) → rhino NullPointerException with String.prototype.replace(re, func)
You need to log in
before you can comment on or make changes to this bug.
Description
•