Skip to content

Commit c965241

Browse files
committed
[MERGE #6001 @MikeHolman] fix assert parsing invalid asm.js module
Merge pull request #6001 from MikeHolman:asmparsebug Malformed "use asm" statement could cause benign assert in asm.js parser. Reject the malformed asm.js instead of asserting. Fixes #5996
2 parents 949143c + ceef69a commit c965241

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

lib/Runtime/Language/AsmJsUtils.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ namespace Js
3737
ParseNode* rhs = GetBinaryRight( body );
3838
if( rhs && rhs->nop == knopList )
3939
{
40-
AssertMsg( lhs->nop == knopStr, "this should be use asm" );
40+
if (lhs->nop != knopStr)
41+
{
42+
return false;
43+
}
4144
*var = rhs;
4245
return true;
4346
}

test/AsmJs/rlexe.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,13 @@
10021002
<tags>exclude_drt</tags>
10031003
</default>
10041004
</test>
1005+
<test>
1006+
<default>
1007+
<files>useasmbug.js</files>
1008+
<baseline>useasmbug.baseline</baseline>
1009+
<compile-flags>-testtrace:asmjs</compile-flags>
1010+
</default>
1011+
</test>
10051012
<test>
10061013
<default>
10071014
<files>lambda.js</files>

test/AsmJs/useasmbug.baseline

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Asm.js compilation failed.

test/AsmJs/useasmbug.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+
6+
function $() {
7+
"use asm"
8+
( );
9+
return
10+
}

0 commit comments

Comments
 (0)