summaryrefslogtreecommitdiff
path: root/src/binary-reader.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/binary-reader.cc')
-rw-r--r--src/binary-reader.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/binary-reader.cc b/src/binary-reader.cc
index 518abe63..bf6222da 100644
--- a/src/binary-reader.cc
+++ b/src/binary-reader.cc
@@ -1433,6 +1433,8 @@ Result BinaryReader::ReadFunctionBody(Offset end_offset) {
case Opcode::MemoryInit: {
Index segment;
+ ERROR_IF(data_count_ == kInvalidIndex,
+ "memory.init requires data count section");
CHECK_RESULT(ReadIndex(&segment, "elem segment index"));
uint8_t reserved;
CHECK_RESULT(ReadU8(&reserved, "reserved memory index"));
@@ -1443,6 +1445,9 @@ Result BinaryReader::ReadFunctionBody(Offset end_offset) {
}
case Opcode::DataDrop:
+ ERROR_IF(data_count_ == kInvalidIndex,
+ "data.drop requires data count section");
+ // Fallthrough.
case Opcode::ElemDrop: {
Index segment;
CHECK_RESULT(ReadIndex(&segment, "segment index"));