Skip to content

Commit

Permalink
[MERGE #6001 @MikeHolman] fix assert parsing invalid asm.js module
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MikeHolman committed Apr 8, 2019
2 parents 949143c + ceef69a commit c965241
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/Runtime/Language/AsmJsUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ namespace Js
ParseNode* rhs = GetBinaryRight( body );
if( rhs && rhs->nop == knopList )
{
AssertMsg( lhs->nop == knopStr, "this should be use asm" );
if (lhs->nop != knopStr)
{
return false;
}
*var = rhs;
return true;
}
Expand Down
7 changes: 7 additions & 0 deletions test/AsmJs/rlexe.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,13 @@
<tags>exclude_drt</tags>
</default>
</test>
<test>
<default>
<files>useasmbug.js</files>
<baseline>useasmbug.baseline</baseline>
<compile-flags>-testtrace:asmjs</compile-flags>
</default>
</test>
<test>
<default>
<files>lambda.js</files>
Expand Down
1 change: 1 addition & 0 deletions test/AsmJs/useasmbug.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Asm.js compilation failed.
10 changes: 10 additions & 0 deletions test/AsmJs/useasmbug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

function $() {
"use asm"
( );
return
}

0 comments on commit c965241

Please sign in to comment.