From c25c06409c29bf35764be551ebd8bccae0ada383 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Wed, 5 May 2021 20:11:14 -0400 Subject: [PATCH] [spv-in] fix casting length expectations --- src/front/spv/mod.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/front/spv/mod.rs b/src/front/spv/mod.rs index dbe39bc0cf..2b2979ce15 100644 --- a/src/front/spv/mod.rs +++ b/src/front/spv/mod.rs @@ -1673,6 +1673,7 @@ impl> Parser { | Op::ConvertUToF | Op::ConvertFToU | Op::ConvertFToS + | Op::FConvert | Op::UConvert | Op::SConvert => { inst.expect_at_least(4)?; @@ -3143,7 +3144,7 @@ impl> Parser { module: &mut crate::Module, ) -> Result<(), Error> { self.switch(ModuleState::Type, inst.op)?; - inst.expect_at_least(3)?; + inst.expect_at_least(4)?; let type_id = self.next()?; let id = self.next()?; let type_lookup = self.lookup_type.lookup(type_id)?; @@ -3156,7 +3157,7 @@ impl> Parser { } => { let low = self.next()?; let high = if width > 4 { - inst.expect(4)?; + inst.expect(5)?; self.next()? } else { 0 @@ -3172,7 +3173,7 @@ impl> Parser { } => { let low = self.next()?; let high = if width > 4 { - inst.expect(4)?; + inst.expect(5)?; self.next()? } else { 0 @@ -3192,11 +3193,11 @@ impl> Parser { let extended = match width { 4 => f64::from(f32::from_bits(low)), 8 => { - inst.expect(4)?; + inst.expect(5)?; let high = self.next()?; f64::from_bits((u64::from(high) << 32) | u64::from(low)) } - _ => return Err(Error::InvalidTypeWidth(u32::from(width))), + _ => return Err(Error::InvalidTypeWidth(width as u32)), }; crate::ConstantInner::Scalar { width,