Skip to content

Commit 62f9668

Browse files
committed
[MERGE #2272 @obastemur] asmjs: anonymous function crash
Merge pull request #2272 from obastemur:fix_asmjs_crash
2 parents 41779e7 + 5449f72 commit 62f9668

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

lib/Jsrt/ChakraCore.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ JsGetModuleHostInfo(
163163
_In_ JsModuleHostInfoKind moduleHostInfo,
164164
_Outptr_result_maybenull_ void** hostInfo);
165165

166+
#ifdef CHAKRACOREBUILD_
166167
/// <summary>
167168
/// Called by the runtime to load the source code of the serialized script.
168169
/// </summary>
@@ -493,5 +494,5 @@ CHAKRA_API
493494
_In_ JsSourceContext sourceContext,
494495
_In_ JsValueRef sourceUrl,
495496
_Out_ JsValueRef *result);
496-
497+
#endif // CHAKRACOREBUILD_
497498
#endif // _CHAKRACORE_H_

lib/Runtime/Language/AsmJsModule.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,11 @@ namespace Js
10801080
AsmJsFunc* AsmJsModuleCompiler::CreateNewFunctionEntry( ParseNode* pnodeFnc )
10811081
{
10821082
PropertyName name = ParserWrapper::FunctionName( pnodeFnc );
1083+
if ( !name )
1084+
{
1085+
return nullptr;
1086+
}
1087+
10831088
GetByteCodeGenerator()->AssignPropertyId(name);
10841089
AsmJsFunc* func = Anew( &mAllocator, AsmJsFunc, name, pnodeFnc, &mAllocator, mCx->scriptContext );
10851090
if( func )

test/AsmJs/bugGH2270.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
(function(){});
9+
})();
10+
11+
print("Pass");

test/AsmJs/rlexe.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,5 +813,8 @@
813813
<baseline>vardeclnorhs.baseline</baseline>
814814
<compile-flags>-testtrace:asmjs -maic:1</compile-flags>
815815
</default>
816+
<default>
817+
<files>bugGH2270.js</files>
818+
</default>
816819
</test>
817820
</regress-exe>

0 commit comments

Comments
 (0)