AsmAnalysis: Fix out of bounds read due to incorrect bounds checking on literal arguments

This commit is contained in:
Bhargava Shastry 2020-12-15 15:38:59 +01:00
parent 4e86390e40
commit 9b38176c77
3 changed files with 17 additions and 1 deletions

View File

@ -332,7 +332,11 @@ vector<YulString> AsmAnalyzer::operator()(FunctionCall const& _funCall)
for (size_t i = _funCall.arguments.size(); i > 0; i--)
{
Expression const& arg = _funCall.arguments[i - 1];
if (auto literalArgumentKind = literalArguments ? literalArguments->at(i - 1) : std::nullopt)
if (
auto literalArgumentKind = (literalArguments && i <= literalArguments->size()) ?
literalArguments->at(i - 1) :
std::nullopt
)
{
if (!holds_alternative<Literal>(arg))
m_errorReporter.typeError(

View File

@ -0,0 +1,6 @@
{
function f(a,b) {}
f(x,1)
}
// ----
// DeclarationError 8198: (27-28): Identifier not found.

View File

@ -0,0 +1,6 @@
{
let x
function f(a,b) {}
f(x,1)
}
// ----