Skip to content

Commit 8a17030

Browse files
committed
Yul: NoOutputAssembly assigns functions instead of appending
There was an error in that the functions were already part of the dialect (via the parent constructor) and the no output versions were appended instead of overwritten. This causes the vector to be re-allocated and therefore could invalidate pointers to its elements.
1 parent 1d21bb4 commit 8a17030

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

libyul/backends/evm/NoOutputAssembly.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,13 @@ NoOutputEVMDialect::NoOutputEVMDialect(EVMDialect const& _copyFrom):
212212
// them in one go, later reference pointers to this static vector
213213
static std::vector<BuiltinFunctionForEVM> noOutputBuiltins = defineNoOutputBuiltins();
214214

215-
m_functions.reserve(m_functions.size());
215+
yulAssert(m_functions.size() == noOutputBuiltins.size(), "Function count mismatch.");
216216
for (auto const& [index, builtinFunction]: m_functions | ranges::views::enumerate)
217217
{
218218
if (builtinFunction)
219-
m_functions.emplace_back(&noOutputBuiltins[index]);
219+
m_functions[index] = &noOutputBuiltins[index];
220220
else
221-
m_functions.emplace_back(nullptr);
221+
m_functions[index] = nullptr;
222222
}
223223
}
224224

0 commit comments

Comments
 (0)