Skip to content

Commit

Permalink
Merge pull request #11416 from ethereum/fix-asan-stack-use-after-scop…
Browse files Browse the repository at this point in the history
…e-in-test-file-parser-test

Fix asan stack-use-after-scope in TestFileParserTest
  • Loading branch information
Leonardo authored May 20, 2021
2 parents d07c85d + d85cc6c commit 1239c0c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions test/libsolidity/util/TestFileParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ char TestFileParser::Scanner::scanHexPart()
return static_cast<char>(value);
}

bool TestFileParser::isBuiltinFunction(std::string const& signature)
bool TestFileParser::isBuiltinFunction(std::string const& _signature)
{
return m_builtins.count(signature) > 0;
return m_builtins.count(_signature) > 0;
}
7 changes: 5 additions & 2 deletions test/libsolidity/util/TestFileParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ class TestFileParser
public:
/// Constructor that takes an input stream \param _stream to operate on
/// and creates the internal scanner.
explicit TestFileParser(std::istream& _stream, std::map<std::string, Builtin> const& _builtins): m_scanner(_stream), m_builtins(_builtins) {}
explicit TestFileParser(std::istream& _stream, std::map<std::string, Builtin> const& _builtins):
m_scanner(_stream),
m_builtins(_builtins)
{}

/// Parses function calls blockwise and returns a list of function calls found.
/// Throws an exception if a function call cannot be parsed because of its
Expand Down Expand Up @@ -179,7 +182,7 @@ class TestFileParser

/// Checks whether a builtin function with the given signature exist.
/// @returns true, if builtin found, false otherwise
bool isBuiltinFunction(std::string const& signature);
bool isBuiltinFunction(std::string const& _signature);

/// A scanner instance
Scanner m_scanner;
Expand Down
7 changes: 4 additions & 3 deletions test/libsolidity/util/TestFileParserTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ namespace

vector<FunctionCall> parse(string const& _source)
{
static std::map<std::string, Builtin> const builtins = {};

istringstream stream{_source, ios_base::out};
TestFileParser parser{stream, {}};
return parser.parseFunctionCalls(0);
return TestFileParser{stream, builtins}.parseFunctionCalls(0);
}

void testFunctionCall(
Expand Down Expand Up @@ -99,7 +100,7 @@ BOOST_AUTO_TEST_CASE(smoke_test)
BOOST_REQUIRE_EQUAL(parse(source).size(), 0);
}

BOOST_AUTO_TEST_CASE(call_succees)
BOOST_AUTO_TEST_CASE(call_success)
{
char const* source = R"(
// success() ->
Expand Down

0 comments on commit 1239c0c

Please sign in to comment.