Skip to content

Commit 826cc82

Browse files
committed
[MERGE #790] fix for crash while processing asmjs var decl w/o a RHS
Merge pull request #790 from Krovatkin:norhs2 adding a nullptr check for a rhs node + unit test
2 parents c8f39a9 + ed57fea commit 826cc82

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

lib/Runtime/Language/AsmJsModule.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,11 @@ namespace Js
854854
mathFunc = nullptr;
855855
simdFunc = nullptr;
856856

857+
if (!pnodeInit)
858+
{
859+
return Fail(decl, _u("The righthand side of a var declaration missing an initialization (empty)"));
860+
}
861+
857862
if (pnodeInit->nop == knopName)
858863
{
859864
declSym = LookupIdentifier(pnodeInit->name(), func);

test/AsmJs/rlexe.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,4 +800,11 @@
800800
<compile-flags>-testtrace:asmjs -maic:1</compile-flags>
801801
</default>
802802
</test>
803+
<test>
804+
<default>
805+
<files>vardeclnorhs.js</files>
806+
<baseline>vardeclnorhs.baseline</baseline>
807+
<compile-flags>-testtrace:asmjs -maic:1</compile-flags>
808+
</default>
809+
</test>
803810
</regress-exe>

test/AsmJs/vardeclnorhs.baseline

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The righthand side of a var declaration missing an initialization (empty)
2+
Asm.js compilation failed.

test/AsmJs/vardeclnorhs.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
function module(stdlib) {
6+
"use asm"
7+
function foo() {
8+
var abc;
9+
}
10+
}

0 commit comments

Comments
 (0)