mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Ensure that public callable parameters are valid for calldata.
This commit is contained in:
@@ -488,6 +488,8 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
|
||||
if (auto referenceType = dynamic_cast<ReferenceType const*>(varType))
|
||||
{
|
||||
auto result = referenceType->validForLocation(referenceType->location());
|
||||
if (result && _variable.isPublicCallableParameter())
|
||||
result = referenceType->validForLocation(DataLocation::CallData);
|
||||
if (!result)
|
||||
{
|
||||
solAssert(!result.message().empty(), "Expected detailed error message");
|
||||
|
||||
@@ -559,6 +559,18 @@ bool VariableDeclaration::isExternalCallableParameter() const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VariableDeclaration::isPublicCallableParameter() const
|
||||
{
|
||||
if (!isCallableOrCatchParameter())
|
||||
return false;
|
||||
|
||||
if (auto const* callable = dynamic_cast<CallableDeclaration const*>(scope()))
|
||||
if (callable->visibility() == Visibility::Public)
|
||||
return !isReturnParameter();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VariableDeclaration::isInternalCallableParameter() const
|
||||
{
|
||||
if (!isCallableOrCatchParameter())
|
||||
|
||||
@@ -914,6 +914,8 @@ public:
|
||||
/// @returns true if this variable is a parameter (not return parameter) of an external function.
|
||||
/// This excludes parameters of external function type names.
|
||||
bool isExternalCallableParameter() const;
|
||||
/// @returns true if this variable is a parameter (not return parameter) of a public function.
|
||||
bool isPublicCallableParameter() const;
|
||||
/// @returns true if this variable is a parameter or return parameter of an internal function
|
||||
/// or a function type of internal visibility.
|
||||
bool isInternalCallableParameter() const;
|
||||
|
||||
Reference in New Issue
Block a user