From 469d6d4d2933b2a1bf72339e59b912d4b0b6cba7 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Thu, 5 Jan 2023 18:26:49 +0100 Subject: [PATCH] Fix segfault. --- libsolidity/interface/CompilerStack.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index cacfc95aa..52bd54d16 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -765,7 +765,8 @@ evmasm::AssemblyItems const* CompilerStack::assemblyItems(string const& _contrac solThrow(CompilerError, "Compilation was not successful."); Contract const& currentContract = contract(_contractName); - solAssert(currentContract.evmAssembly->codeSections().size() == 1, "Expected a single code section in legacy codegen."); + if (currentContract.evmAssembly) + solAssert(currentContract.evmAssembly->codeSections().size() == 1, "Expected a single code section in legacy codegen."); return currentContract.evmAssembly ? ¤tContract.evmAssembly->codeSections().front().items : nullptr; } @@ -775,7 +776,8 @@ evmasm::AssemblyItems const* CompilerStack::runtimeAssemblyItems(string const& _ solThrow(CompilerError, "Compilation was not successful."); Contract const& currentContract = contract(_contractName); - solAssert(currentContract.evmRuntimeAssembly->codeSections().size() == 1, "Expected a single code section in legacy codegen."); + if (currentContract.evmRuntimeAssembly) + solAssert(currentContract.evmRuntimeAssembly->codeSections().size() == 1, "Expected a single code section in legacy codegen."); return currentContract.evmRuntimeAssembly ? ¤tContract.evmRuntimeAssembly->codeSections().front().items : nullptr; }