-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
bugSomething isn't workingSomething isn't working
Description
The implementation of deserialization for Vec and BTreeMap, in indefinite length case, will assume that if it finds an item of type Special, it must be the Special::Break indicating the end of the indefinite-length item. However, bools (and other things like Null and Undefined) are also encoded as a Special.
Sample code to reproduce the problem:
use cbor_event::Deserialize;
fn main() -> anyhow::Result<()> {
let mut s = cbor_event::se::Serializer::new_vec();
cbor_event::se::serialize_indefinite_array([false, true, false].iter(), &mut s)?;
let encoded = s.finalize();
let v = Vec::<bool>::deserialize(&mut cbor_event::de::Deserializer::from(encoded.as_slice()))?;
println!("{:?}", v);
Ok(())
}This produces:
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `Bool(false)`,
right: `Break`', /rustc/d3fb005a39e62501b8b0b356166e515ae24e2e54/src/libstd/macros.rs:16:9
Currently working on a fix.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working