diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/wast-parser.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/wast-parser.cc b/src/wast-parser.cc index 5954f651..1be01dda 100644 --- a/src/wast-parser.cc +++ b/src/wast-parser.cc @@ -2363,7 +2363,13 @@ Result WastParser::ParseF32(Const* const_, ConstType const_type) { const_->set_f32(expected); return Result::Ok; } - auto literal = Consume().literal(); + + auto token = Consume(); + if (!token.HasLiteral()) { + return Result::Error; + } + + auto literal = token.literal(); uint32_t f32_bits; Result result = ParseFloat(literal.type, literal.text.begin(), literal.text.end(), &f32_bits); @@ -2378,7 +2384,13 @@ Result WastParser::ParseF64(Const* const_, ConstType const_type) { const_->set_f64(expected); return Result::Ok; } - auto literal = Consume().literal(); + + auto token = Consume(); + if (!token.HasLiteral()) { + return Result::Error; + } + + auto literal = token.literal(); uint64_t f64_bits; Result result = ParseDouble(literal.type, literal.text.begin(), literal.text.end(), &f64_bits); |