mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWasm: Validate that function and code sections match
This commit is contained in:
parent
67749300c3
commit
94c2b85959
Notes:
sideshowbarker
2024-07-17 02:39:10 +09:00
Author: https://github.com/dzfrias
Commit: 94c2b85959
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/134
1 changed files with 8 additions and 1 deletions
|
@ -1483,12 +1483,17 @@ bool Module::populate_sections()
|
|||
{
|
||||
auto is_ok = true;
|
||||
FunctionSection const* function_section { nullptr };
|
||||
bool seen_code_section = false;
|
||||
for_each_section_of_type<FunctionSection>([&](FunctionSection const& section) { function_section = §ion; });
|
||||
for_each_section_of_type<CodeSection>([&](CodeSection const& section) {
|
||||
if (!function_section) {
|
||||
if (!function_section && section.functions().is_empty()) {
|
||||
return;
|
||||
}
|
||||
if (!function_section || function_section->types().size() != section.functions().size()) {
|
||||
is_ok = false;
|
||||
return;
|
||||
}
|
||||
seen_code_section = true;
|
||||
size_t index = 0;
|
||||
for (auto& entry : section.functions()) {
|
||||
if (function_section->types().size() <= index) {
|
||||
|
@ -1505,6 +1510,8 @@ bool Module::populate_sections()
|
|||
++index;
|
||||
}
|
||||
});
|
||||
if (!seen_code_section && function_section && !function_section->types().is_empty())
|
||||
return false;
|
||||
return is_ok;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue