Skip to content

Commit c3fd65f

Browse files
author
Kevin Smith
committed
[MERGE #6134 @rhuanjl] Fix #6133 nullptr deref for non-existant default import
Merge pull request #6134 from rhuanjl:fixChildModuleInvalidImport Properly check for a child module that errors in failing to find an import after previously having been parsed correctly. This is a slightly weird bug I accidentally introduced whilst fixing circular imports a year ago - sorry about this. Fixes #6133
2 parents 4d2b4c7 + ae39c2f commit c3fd65f

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

lib/Runtime/Language/SourceTextModuleRecord.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -691,9 +691,6 @@ namespace Js
691691

692692
if (exportName == PropertyIds::default_)
693693
{
694-
JavascriptError* errorObj = scriptContext->GetLibrary()->CreateSyntaxError();
695-
JavascriptError::SetErrorMessage(errorObj, JSERR_ModuleResolveExport, scriptContext->GetPropertyName(exportName)->GetBuffer(), scriptContext);
696-
this->errorObject = errorObj;
697694
return false;
698695
}
699696

@@ -919,10 +916,6 @@ namespace Js
919916

920917
if (this->errorObject != nullptr)
921918
{
922-
OUTPUT_TRACE_DEBUGONLY(Js::ModulePhase, _u("\t>NotifyParentsAsNeeded (errorObject)\n"));
923-
// Cleanup in case of error.
924-
this->ReleaseParserResourcesForHierarchy();
925-
NotifyParentsAsNeeded();
926919
return false;
927920
}
928921

test/es6module/module-bugfixes.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ var tests = [
120120
assert.isTrue(aliasName());
121121
`);
122122
}
123+
},
124+
{
125+
name : "Issue 6133: Child module imports non-existant export from another module",
126+
body()
127+
{
128+
WScript.RegisterModuleSource("test6133a", 'import Default from "test6133b";');
129+
WScript.RegisterModuleSource("test6133b", 'export function notDefault () {}');
130+
131+
testRunner.LoadModule('import "test6133a";', undefined, true);
132+
}
123133
}
124134
];
125135

0 commit comments

Comments
 (0)