summaryrefslogtreecommitdiff
path: root/src/binary-reader-ir.cc
diff options
context:
space:
mode:
authorKeith Winstein <keithw@cs.stanford.edu>2023-05-03 22:34:20 -0700
committerGitHub <noreply@github.com>2023-05-03 22:34:20 -0700
commitaebf63d2e3b26db3e7d76374f3906c50a0f02085 (patch)
tree70529520aa8040009de48c6cd2059a1a8806b730 /src/binary-reader-ir.cc
parent5abbeaab97eb802acccf866d9c8cc021c1f7e570 (diff)
downloadwabt-aebf63d2e3b26db3e7d76374f3906c50a0f02085.tar.gz
wabt-aebf63d2e3b26db3e7d76374f3906c50a0f02085.tar.bz2
wabt-aebf63d2e3b26db3e7d76374f3906c50a0f02085.zip
BinaryReader/BinaryReaderIR: check for missing end markers (#2218)
Diffstat (limited to 'src/binary-reader-ir.cc')
-rw-r--r--src/binary-reader-ir.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/binary-reader-ir.cc b/src/binary-reader-ir.cc
index 2d21a6ce..9eba058b 100644
--- a/src/binary-reader-ir.cc
+++ b/src/binary-reader-ir.cc
@@ -449,6 +449,10 @@ Result BinaryReaderIR::TopLabelExpr(LabelNode** label, Expr** expr) {
CHECK_RESULT(TopLabel(label));
LabelNode* parent_label;
CHECK_RESULT(GetLabelAt(&parent_label, 1));
+ if (parent_label->exprs->empty()) {
+ PrintError("TopLabelExpr: parent label has empty expr list");
+ return Result::Error;
+ }
*expr = &parent_label->exprs->back();
return Result::Ok;
}
@@ -1217,6 +1221,10 @@ Result BinaryReaderIR::OnUnreachableExpr() {
Result BinaryReaderIR::EndFunctionBody(Index index) {
current_func_ = nullptr;
+ if (!label_stack_.empty()) {
+ PrintError("function %" PRIindex " missing end marker", index);
+ return Result::Error;
+ }
return Result::Ok;
}
@@ -1297,6 +1305,10 @@ Result BinaryReaderIR::BeginElemSegmentInitExpr(Index index) {
}
Result BinaryReaderIR::EndInitExpr() {
+ if (!label_stack_.empty()) {
+ PrintError("init expression missing end marker");
+ return Result::Error;
+ }
return Result::Ok;
}