Skip to content

Commit 8fb555a

Browse files
committed
Fix null dereference in BindPidRefsInScope
Fixes #6239
1 parent 9e54d66 commit 8fb555a

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

lib/Parser/Parse.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,10 +1979,10 @@ void Parser::BindPidRefsInScope(IdentPtr pid, Symbol *sym, int blockId, uint max
19791979
Assert(funcExprScope->GetScopeType() == ScopeType_FuncExpr);
19801980

19811981
ParseNodeBlock* bodyScope = m_currentNodeFunc->pnodeBodyScope;
1982-
Assert(bodyScope->blockType == PnodeBlockType::Function);
19831982

1984-
if (ref->GetScopeId() < bodyScope->blockId && ref->GetScopeId() > blockId)
1983+
if (bodyScope && ref->GetScopeId() < bodyScope->blockId && ref->GetScopeId() > blockId)
19851984
{
1985+
Assert(bodyScope->blockType == PnodeBlockType::Function);
19861986
funcExprScope->SetIsObject();
19871987
}
19881988
}

test/Bugs/bug_6239.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
6+
// force:deferparse
7+
8+
(function v2(a = function v2(){ +v2; }) {
9+
a();
10+
console.log('pass');
11+
})();
12+
13+
(function v2(a = function v3(){ function v4(b = (function v4() {v4; console.log('pass');})()){}; v4(); }) {
14+
a();
15+
console.log('pass');
16+
})();
17+
18+
(function a() {
19+
a = function a(a=function(a){}){}
20+
function a(){
21+
var a = "a";
22+
}
23+
console.log('pass');
24+
})();

test/Bugs/rlexe.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,4 +612,10 @@
612612
<compile-flags>-maxinterpretcount:1 -maxsimplejitruncount:2 -args summary -endargs</compile-flags>
613613
</default>
614614
</test>
615+
<test>
616+
<default>
617+
<files>bug_6239.js</files>
618+
<compile-flags>-force:deferparse</compile-flags>
619+
</default>
620+
</test>
615621
</regress-exe>

0 commit comments

Comments
 (0)