diff --git a/Cargo.lock b/Cargo.lock index d0334fe3..6ed7a8b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -257,7 +257,7 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "candid" -version = "0.9.9" +version = "0.9.10" dependencies = [ "anyhow", "arbitrary", diff --git a/rust/candid/Cargo.toml b/rust/candid/Cargo.toml index cd1aa777..5351fcbf 100644 --- a/rust/candid/Cargo.toml +++ b/rust/candid/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "candid" -version = "0.9.9" +version = "0.9.10" edition = "2021" authors = ["DFINITY Team"] description = "Candid is an interface description language (IDL) for interacting with canisters running on the Internet Computer." diff --git a/rust/candid/src/de.rs b/rust/candid/src/de.rs index 3e8404fe..036440c6 100644 --- a/rust/candid/src/de.rs +++ b/rust/candid/src/de.rs @@ -423,7 +423,11 @@ impl<'de> Deserializer<'de> { where V: Visitor<'de>, { - Err(Error::subtype("Cannot decode empty type")) + Err(if *self.wire_type == TypeInner::Empty { + Error::msg("Cannot decode empty type") + } else { + Error::subtype("Cannot decode empty type") + }) } fn deserialize_future<'a, V>(&'a mut self, visitor: V) -> Result where diff --git a/rust/candid/src/types/value.rs b/rust/candid/src/types/value.rs index 89ac3cf5..a2676218 100644 --- a/rust/candid/src/types/value.rs +++ b/rust/candid/src/types/value.rs @@ -451,8 +451,7 @@ impl<'de> Visitor<'de> for IDLValueVisitor { 5u8 => { use std::io::Read; let len = leb128::read::unsigned(&mut bytes).map_err(E::custom)? as usize; - let mut buf = Vec::new(); - buf.resize(len, 0); + let mut buf = vec![0; len]; bytes.read_exact(&mut buf).map_err(E::custom)?; let meth = String::from_utf8(buf).map_err(E::custom)?; let id = crate::Principal::try_from(bytes).map_err(E::custom)?;