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