diff options
author | Ben Smith <binjimin@gmail.com> | 2018-11-05 11:59:14 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-05 11:59:14 -0800 |
commit | 61372aad2bb3379a0c16ee052568eb7f69b02114 (patch) | |
tree | 58c5256f5bc3200455021964017075f27e2f48ed /src | |
parent | b1b50452a297ec60f20bc7235ecfb82c7ab907a9 (diff) | |
download | wabt-61372aad2bb3379a0c16ee052568eb7f69b02114.tar.gz wabt-61372aad2bb3379a0c16ee052568eb7f69b02114.tar.bz2 wabt-61372aad2bb3379a0c16ee052568eb7f69b02114.zip |
Update testsuite (#942)
Also fix bug when parsing elem/data segment; the table/memory index is
stored as an LEB128, not a U8.
Diffstat (limited to 'src')
-rw-r--r-- | src/binary-reader.cc | 16 | ||||
-rw-r--r-- | src/binary.h | 2 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/binary-reader.cc b/src/binary-reader.cc index c36cca4e..d5ec2346 100644 --- a/src/binary-reader.cc +++ b/src/binary-reader.cc @@ -1963,9 +1963,11 @@ Result BinaryReader::ReadElemSection(Offset section_size) { ERROR_UNLESS(num_elem_segments == 0 || NumTotalTables() > 0, "elem section without table section"); for (Index i = 0; i < num_elem_segments; ++i) { - uint8_t flags_byte; - CHECK_RESULT(ReadU8(&flags_byte, "elem segment flags")); - SegmentFlags flags = static_cast<SegmentFlags>(flags_byte); + uint32_t flags_u32; + CHECK_RESULT(ReadU32Leb128(&flags_u32, "elem segment flags")); + ERROR_UNLESS(flags_u32 <= static_cast<uint32_t>(SegmentFlags::IndexOther), + "invalid elem segment flags"); + SegmentFlags flags = static_cast<SegmentFlags>(flags_u32); Index table_index(0); if (flags == SegmentFlags::IndexOther) { CHECK_RESULT(ReadIndex(&table_index, "elem segment table index")); @@ -2041,9 +2043,11 @@ Result BinaryReader::ReadDataSection(Offset section_size) { ERROR_UNLESS(num_data_segments == 0 || NumTotalMemories() > 0, "data section without memory section"); for (Index i = 0; i < num_data_segments; ++i) { - uint8_t flags_byte; - CHECK_RESULT(ReadU8(&flags_byte, "data segment flags")); - SegmentFlags flags = static_cast<SegmentFlags>(flags_byte); + uint32_t flags_u32; + CHECK_RESULT(ReadU32Leb128(&flags_u32, "data segment flags")); + ERROR_UNLESS(flags_u32 <= static_cast<uint32_t>(SegmentFlags::IndexOther), + "invalid data segment flags"); + SegmentFlags flags = static_cast<SegmentFlags>(flags_u32); Index memory_index(0); if (flags == SegmentFlags::IndexOther) { CHECK_RESULT(ReadIndex(&memory_index, "data segment memory index")); diff --git a/src/binary.h b/src/binary.h index 7f62092e..606872f6 100644 --- a/src/binary.h +++ b/src/binary.h @@ -64,7 +64,7 @@ enum class NameSectionSubsection { Local = 2, }; -enum class SegmentFlags: uint8_t { +enum class SegmentFlags : uint8_t { IndexZero = 0, Passive = 1, IndexOther = 2, |