@@ -639,24 +639,25 @@ std::variant<EOFValidationError, int32_t> validate_max_stack_height(
639
639
640
640
EOFValidationError validate_eof1 (evmc_revision rev, bytes_view main_container) noexcept
641
641
{
642
- const auto error_or_header = validate_header (rev, main_container);
643
- if (const auto * error = std::get_if<EOFValidationError>(&error_or_header))
644
- return *error;
645
- const auto & main_container_header = std::get<EOF1Header>(error_or_header);
646
-
647
642
struct Container
648
643
{
649
644
bytes_view bytes;
650
- EOF1Header header;
651
645
bool referenced_by_eofcreate = false ;
652
646
};
653
647
// Queue of containers left to process
654
648
std::queue<Container> container_queue;
655
- container_queue.emplace ( main_container, main_container_header, false );
649
+ container_queue.push ({ main_container, false } );
656
650
657
651
while (!container_queue.empty ())
658
652
{
659
- const auto & [container, header, referenced_by_eofcreate] = container_queue.front ();
653
+ const auto & [container, referenced_by_eofcreate] = container_queue.front ();
654
+
655
+ // Validate header
656
+ auto error_or_header = validate_header (rev, container);
657
+ if (const auto * error = std::get_if<EOFValidationError>(&error_or_header))
658
+ return *error;
659
+
660
+ auto & header = std::get<EOF1Header>(error_or_header);
660
661
661
662
// Validate code sections
662
663
std::vector<bool > visited_code_sections (header.code_sizes .size ());
@@ -720,16 +721,7 @@ EOFValidationError validate_eof1(evmc_revision rev, bytes_view main_container) n
720
721
{
721
722
const bytes_view subcontainer{header.get_container (container, subcont_idx)};
722
723
723
- auto error_subcont_or_header = validate_header (rev, subcontainer);
724
- if (const auto * error_subcont =
725
- std::get_if<EOFValidationError>(&error_subcont_or_header))
726
- return *error_subcont;
727
-
728
- auto & subcont_header = std::get<EOF1Header>(error_subcont_or_header);
729
-
730
- container_queue.emplace (subcontainer, std::move (subcont_header),
731
- subcontainer_referenced_by_eofcreate[subcont_idx],
732
- subcontainer_referenced_by_returncontract[subcont_idx]);
724
+ container_queue.push ({subcontainer, subcontainer_referenced_by_eofcreate[subcont_idx]});
733
725
}
734
726
735
727
container_queue.pop ();
0 commit comments