Closed
Bug 286251
Opened 20 years ago
Closed 20 years ago
initFunction can be called twice
Categories
(Rhino Graveyard :: Core, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: gilles.barnier, Assigned: igor)
Details
Attachments
(1 file)
1.06 KB,
patch
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705)
Build Identifier: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705)
While surfing to the following page:
<html>
<body>
<form name="form1" method="get">
First Name <input type="text" name="firstName" value="John"><br>
Last Name <input type="text" name="lastName" value="Doe"><br>
<input type="submit" value="Submit>>" name="submit">
</form>
<div id="div1"></div>
<script>
<!--
function window.onload()
{
document.getElementById("div1").innerText = "onload triggered";
}
//-->
</script>
</body>
</html>
The Rhino javascript engine will enter into an infinite loop.
This is due to an incorrect function parse tree because of a redundant
initialization.
The source of the problem is in the function method at
org.mozilla.javascript.parser.
The problematic code is:
Node pn = nf.initFunction(fnNode, functionIndex, body, syntheticType);
if (memberExprNode != null) {
pn = nf.initFunction(fnNode, functionIndex, body, syntheticType);
pn = nf.createAssignment(Token.ASSIGN, memberExprNode, pn);
if (functionType != FunctionNode.FUNCTION_EXPRESSION) {
// XXX check JScript behavior: should it be createExprStatement?
pn = nf.createExprStatementNoReturn(pn, baseLineno);
}
}
As you can see in the code, the initFunction can be called twice. The
html example above leads to that redundant initialization.
We suggest removing the second call to the function method.
Reproducible: Always
The MIT License
Copyright (c) 2005 VERITAS Operating Company
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Assignee | ||
Comment 1•20 years ago
|
||
Assignee | ||
Comment 2•20 years ago
|
||
I committed the fix, thanks for discovering it!
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•