summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-09-28 15:03:03 -0700
committerGitHub <noreply@github.com>2021-09-28 15:03:03 -0700
commitd8e452412e14a6a8ba137f2adcae13b398e5cecb (patch)
treef7dc748082f4c1e760bf4d2870f76e73870e5855 /source
parentcdf1b2c007fefdca128584d2a9f63dec3d350e16 (diff)
Fix AbortCompilationException leaking through loadModule API. (#1949)
* Fix AbortCompilationException leaking through loadModule API. * Update. * Fix. Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index b79d97331..1362cb038 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -822,13 +822,21 @@ SLANG_NO_THROW slang::IModule* SLANG_MCALL Linkage::loadModule(
const char* moduleName,
slang::IBlob** outDiagnostics)
{
- auto name = getNamePool()->getName(moduleName);
+ try
+ {
+ auto name = getNamePool()->getName(moduleName);
- DiagnosticSink sink(getSourceManager(), Lexer::sourceLocationLexer);
- auto module = findOrImportModule(name, SourceLoc(), &sink);
- sink.getBlobIfNeeded(outDiagnostics);
+ DiagnosticSink sink(getSourceManager(), Lexer::sourceLocationLexer);
+ auto module = findOrImportModule(name, SourceLoc(), &sink);
+ sink.getBlobIfNeeded(outDiagnostics);
+
+ return asExternal(module);
- return asExternal(module);
+ }
+ catch (const AbortCompilationException&)
+ {
+ return nullptr;
+ }
}
SLANG_NO_THROW SlangResult SLANG_MCALL Linkage::createCompositeComponentType(
@@ -2454,7 +2462,7 @@ void Linkage::_diagnoseErrorInImportedModule(
{
for(auto info = m_modulesBeingImported; info; info = info->next)
{
- sink->diagnose(info->importLoc, Diagnostics::errorInImportedModule, info->name);
+ sink->diagnose(info->importLoc, Diagnostics::errorInImportedModule, info->name);
}
sink->diagnose(SourceLoc(), Diagnostics::complationCeased);
}