Quellcode durchsuchen

MSFT:18262249 Make sure the parser temp guest arena is released in child module parsing error cases as well.

Atul Katti vor 7 Jahren
Ursprung
Commit
3356597481

+ 15 - 5
lib/Runtime/Language/SourceTextModuleRecord.cpp

@@ -251,6 +251,14 @@ namespace Js
         SetLocalExportRecordList(moduleParseNode->localExportEntries);
     }
 
+    void SourceTextModuleRecord::ReleaseParserResources()
+    {
+        if (this->parser != nullptr)
+        {
+            this->parser->ReleaseTemporaryGuestArena();
+        }
+    }
+
     HRESULT SourceTextModuleRecord::PostParseProcess()
     {
         HRESULT hr = NOERROR;
@@ -262,6 +270,9 @@ namespace Js
         {
             hr = PrepareForModuleDeclarationInitialization();
         }
+
+        this->ReleaseParserResources();
+
         return hr;
     }
 
@@ -305,6 +316,8 @@ namespace Js
                 }
             }
 
+            this->ReleaseParserResources();
+
             if (FAILED(hr))
             {
                 // We cannot just use the buffer in the specifier string - need to make a copy here.
@@ -320,6 +333,8 @@ namespace Js
             }
         }
 
+        this->ReleaseParserResources();
+
         return this->promise;
     }
 
@@ -915,11 +930,6 @@ namespace Js
                 childModuleRecord->GenerateRootFunction();
             });
         }
-
-        if (this->parser != nullptr)
-        {
-            this->parser->ReleaseTemporaryGuestArena();
-        }
     }
 
     Var SourceTextModuleRecord::ModuleEvaluation()

+ 1 - 0
lib/Runtime/Language/SourceTextModuleRecord.h

@@ -159,6 +159,7 @@ namespace Js
 
         HRESULT PostParseProcess();
         HRESULT PrepareForModuleDeclarationInitialization();
+        void ReleaseParserResources();
         void ImportModuleListsFromParser();
         HRESULT OnChildModuleReady(SourceTextModuleRecord* childModule, Var errorObj);
         void NotifyParentsAsNeeded();

+ 7 - 0
test/es6module/module-functionality.js

@@ -361,6 +361,13 @@ var tests = [
                 testRunner.LoadModule(` /x/ ; for(i=0);`, 'samethread', {shouldFail:true});
             }
             catch(e){}
+
+            try
+            {
+                // import non-existent module
+                testRunner.LoadModule(` /x/  ;import 'funfuzz_moduleScript3';`, 'samethread', {shouldFail:true});
+            }
+            catch(e){}
         }
     },
 ];