From ff736fd3e41c7c0deea5d54f7f0b1eda321820ee Mon Sep 17 00:00:00 2001 From: JohnnyMorganz Date: Fri, 14 Oct 2022 15:28:54 +0100 Subject: [PATCH] Fix segfault in `loadDefinition` for unit tests (#705) `module` can be empty if the definition file has syntax errors --- tests/Fixture.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Fixture.cpp b/tests/Fixture.cpp index 4d3c8854f..05c07b90f 100644 --- a/tests/Fixture.cpp +++ b/tests/Fixture.cpp @@ -429,7 +429,8 @@ LoadDefinitionFileResult Fixture::loadDefinition(const std::string& source) LoadDefinitionFileResult result = frontend.loadDefinitionFile(source, "@test"); freeze(typeChecker.globalTypes); - dumpErrors(result.module); + if (result.module) + dumpErrors(result.module); REQUIRE_MESSAGE(result.success, "loadDefinition: unable to load definition file"); return result; }