aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-11-28 23:33:56 +0800
committerGitHub <noreply@github.com>2018-11-28 23:33:56 +0800
commit463951e8cdd9d3d36b4d1b1e1dd41bb8f54bb73c (patch)
tree53a149e1c3a46758b8270747ab0c1fd32737b1e5
parent937891bc0a8494a783a8925c3c4e03e6ccd12f1d (diff)
parent50351fb8e2f318998d73f8e7043a8a56c3a6c06a (diff)
downloaddexon-solidity-463951e8cdd9d3d36b4d1b1e1dd41bb8f54bb73c.tar
dexon-solidity-463951e8cdd9d3d36b4d1b1e1dd41bb8f54bb73c.tar.gz
dexon-solidity-463951e8cdd9d3d36b4d1b1e1dd41bb8f54bb73c.tar.bz2
dexon-solidity-463951e8cdd9d3d36b4d1b1e1dd41bb8f54bb73c.tar.lz
dexon-solidity-463951e8cdd9d3d36b4d1b1e1dd41bb8f54bb73c.tar.xz
dexon-solidity-463951e8cdd9d3d36b4d1b1e1dd41bb8f54bb73c.tar.zst
dexon-solidity-463951e8cdd9d3d36b4d1b1e1dd41bb8f54bb73c.zip
Merge pull request #5530 from ethereum/fix-ast-segfault
Fixes crash on empty runtime code.
-rw-r--r--Changelog.md1
-rw-r--r--solc/CommandLineInterface.cpp16
2 files changed, 11 insertions, 6 deletions
diff --git a/Changelog.md b/Changelog.md
index 4defbbe4..7fd95566 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -16,6 +16,7 @@ Compiler Features:
Bugfixes:
* Assembly output: Do not mix in/out jump annotations with arguments.
+ * Commandline interface: Fix crash when using ``--ast`` on empty runtime code.
* Code Generator: Annotate jump from calldata decoder to function as "jump in".
* Type Checker: Properly detect different return types when overriding an external interface function with a public contract function.
* Optimizer: Fix nondeterminism bug related to the boost version and constants representation. The bug only resulted in less optimal but still correct code because the generated routine is always verified to be correct.
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp
index 7f64d8ac..e2baca7f 100644
--- a/solc/CommandLineInterface.cpp
+++ b/solc/CommandLineInterface.cpp
@@ -1022,12 +1022,16 @@ void CommandLineInterface::handleAst(string const& _argStr)
map<ASTNode const*, eth::GasMeter::GasConsumption> gasCosts;
for (auto const& contract : m_compiler->contractNames())
{
- auto ret = GasEstimator::breakToStatementLevel(
- GasEstimator(m_evmVersion).structuralEstimation(*m_compiler->runtimeAssemblyItems(contract), asts),
- asts
- );
- for (auto const& it: ret)
- gasCosts[it.first] += it.second;
+ if (auto const* assemblyItems = m_compiler->runtimeAssemblyItems(contract))
+ {
+ auto ret = GasEstimator::breakToStatementLevel(
+ GasEstimator(m_evmVersion).structuralEstimation(*assemblyItems, asts),
+ asts
+ );
+ for (auto const& it: ret)
+ gasCosts[it.first] += it.second;
+ }
+
}
bool legacyFormat = !m_args.count(g_argAstCompactJson);