Skip to content

Commit

Permalink
Merge pull request ethereum#290 from chriseth/fix_gas_iterator
Browse files Browse the repository at this point in the history
Fix: Segfaults connected to paramater types.
  • Loading branch information
chriseth committed Dec 10, 2015
2 parents ca10971 + 39f57a9 commit 08cb74a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions libsolidity/analysis/TypeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
else
_functionCall.annotation().type = make_shared<TupleType>(functionType->returnParameterTypes());

TypePointers const& parameterTypes = functionType->parameterTypes();
TypePointers parameterTypes = functionType->parameterTypes();
if (!functionType->takesArbitraryParameters() && parameterTypes.size() != arguments.size())
{
string msg =
Expand Down Expand Up @@ -1079,7 +1079,7 @@ void TypeChecker::endVisit(NewExpression const& _newExpression)
);

auto contractType = make_shared<ContractType>(*contract);
TypePointers const& parameterTypes = contractType->constructorType()->parameterTypes();
TypePointers parameterTypes = contractType->constructorType()->parameterTypes();
_newExpression.annotation().type = make_shared<FunctionType>(
parameterTypes,
TypePointers{contractType},
Expand Down
4 changes: 2 additions & 2 deletions libsolidity/codegen/ExpressionCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void ExpressionCompiler::appendStateVariableAccessor(VariableDeclaration const&
CompilerContext::LocationSetter locationSetter(m_context, _varDecl);
FunctionType accessorType(_varDecl);

TypePointers const& paramTypes = accessorType.parameterTypes();
TypePointers paramTypes = accessorType.parameterTypes();

// retrieve the position of the variable
auto const& location = m_context.storageLocationOfVariable(_varDecl);
Expand Down Expand Up @@ -380,7 +380,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
else
functionType = dynamic_pointer_cast<FunctionType const>(_functionCall.expression().annotation().type);

TypePointers const& parameterTypes = functionType->parameterTypes();
TypePointers parameterTypes = functionType->parameterTypes();
vector<ASTPointer<Expression const>> const& callArguments = _functionCall.arguments();
vector<ASTPointer<ASTString>> const& callArgumentNames = _functionCall.names();
if (!functionType->takesArbitraryParameters())
Expand Down
6 changes: 3 additions & 3 deletions solc/CommandLineInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ void CommandLineInterface::handleGasEstimation(string const& _contract)
gas = GasEstimator::functionalEstimation(*items, entry, *it);
FunctionType type(*it);
cout << " " << it->name() << "(";
auto end = type.parameterTypes().end();
for (auto it = type.parameterTypes().begin(); it != end; ++it)
cout << (*it)->toString() << (it + 1 == end ? "" : ",");
auto paramTypes = type.parameterTypes();
for (auto it = paramTypes.begin(); it != paramTypes.end(); ++it)
cout << (*it)->toString() << (it + 1 == paramTypes.end() ? "" : ",");
cout << "):\t" << gas << endl;
}
}
Expand Down
6 changes: 3 additions & 3 deletions solc/jsonCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ Json::Value estimateGas(CompilerStack const& _compiler, string const& _contract)
gas = GasEstimator::functionalEstimation(*items, entry, *it);
FunctionType type(*it);
string sig = it->name() + "(";
auto end = type.parameterTypes().end();
for (auto it = type.parameterTypes().begin(); it != end; ++it)
sig += (*it)->toString() + (it + 1 == end ? "" : ",");
auto paramTypes = type.parameterTypes();
for (auto it = paramTypes.begin(); it != paramTypes.end(); ++it)
sig += (*it)->toString() + (it + 1 == paramTypes.end() ? "" : ",");
sig += ")";
internalFunctions[sig] = gasToJson(gas);
}
Expand Down

0 comments on commit 08cb74a

Please sign in to comment.