aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-10-16 20:25:58 +0800
committerGitHub <noreply@github.com>2018-10-16 20:25:58 +0800
commitb723893ac76aefb07f7792fb9f16cff72f3e84b0 (patch)
treef4f1ae9003c103ec28b01784f514c0b9ba9297c8
parent036929aba11268eafb602394af8b212fbe56ae6c (diff)
parent9f9d6fdcc48bfbc1c039c903d60aa38a166c1850 (diff)
downloaddexon-solidity-b723893ac76aefb07f7792fb9f16cff72f3e84b0.tar
dexon-solidity-b723893ac76aefb07f7792fb9f16cff72f3e84b0.tar.gz
dexon-solidity-b723893ac76aefb07f7792fb9f16cff72f3e84b0.tar.bz2
dexon-solidity-b723893ac76aefb07f7792fb9f16cff72f3e84b0.tar.lz
dexon-solidity-b723893ac76aefb07f7792fb9f16cff72f3e84b0.tar.xz
dexon-solidity-b723893ac76aefb07f7792fb9f16cff72f3e84b0.tar.zst
dexon-solidity-b723893ac76aefb07f7792fb9f16cff72f3e84b0.zip
Merge pull request #5225 from mestorlx/issue5007
Prevent crash in case there are no contracts
-rw-r--r--Changelog.md1
-rw-r--r--solc/CommandLineInterface.cpp10
-rwxr-xr-xtest/cmdlineTests.sh8
3 files changed, 13 insertions, 6 deletions
diff --git a/Changelog.md b/Changelog.md
index 01599026..5bf194e4 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -132,6 +132,7 @@ Bugfixes:
* Type Checker: Fix internal error when array index is not an unsigned.
* Type System: Allow arbitrary exponents for literals with a mantissa of zero.
* Parser: Fix incorrect source location for nameless parameters.
+ * Command Line Interface: Fix internal error when compiling stdin with no content and --ast option.
### 0.4.25 (2018-09-12)
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp
index 4052ed13..e0c6a2b6 100644
--- a/solc/CommandLineInterface.cpp
+++ b/solc/CommandLineInterface.cpp
@@ -994,16 +994,14 @@ void CommandLineInterface::handleAst(string const& _argStr)
for (auto const& sourceCode: m_sourceCodes)
asts.push_back(&m_compiler->ast(sourceCode.first));
map<ASTNode const*, eth::GasMeter::GasConsumption> gasCosts;
- // FIXME: shouldn't this be done for every contract?
- if (m_compiler->runtimeAssemblyItems(m_compiler->lastContractName()))
+ for (auto const& contract : m_compiler->contractNames())
{
- //NOTE: keep the local variable `ret` to prevent a Heisenbug that could happen on certain mac os platform.
- //See: https://github.com/ethereum/solidity/issues/3718 for details.
auto ret = GasEstimator::breakToStatementLevel(
- GasEstimator(m_evmVersion).structuralEstimation(*m_compiler->runtimeAssemblyItems(m_compiler->lastContractName()), asts),
+ GasEstimator(m_evmVersion).structuralEstimation(*m_compiler->runtimeAssemblyItems(contract), asts),
asts
);
- gasCosts = ret;
+ for (auto const& it: ret)
+ gasCosts[it.first] += it.second;
}
bool legacyFormat = !m_args.count(g_argAstCompactJson);
diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh
index 20254ef4..a8261693 100755
--- a/test/cmdlineTests.sh
+++ b/test/cmdlineTests.sh
@@ -292,6 +292,14 @@ SOLTMPDIR=$(mktemp -d)
if [[ "$result" != 0 ]] ; then
exit 1
fi
+
+ # This should not fail
+ set +e
+ output=$(echo '' | "$SOLC" --ast - 2>/dev/null)
+ set -e
+ if [[ $? != 0 ]] ; then
+ exit 1
+ fi
)
printTask "Testing soljson via the fuzzer..."