Skip to content

Commit

Permalink
Check no additional entry is present when deserializing with UntypedR…
Browse files Browse the repository at this point in the history
…eflectDeserializerVisitor
  • Loading branch information
SkiFire13 committed Jun 12, 2023
1 parent c475e27 commit 95c025c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions crates/bevy_reflect/src/serde/de.rs
Expand Up @@ -8,7 +8,8 @@ use crate::{
};
use erased_serde::Deserializer;
use serde::de::{
self, DeserializeSeed, EnumAccess, Error, MapAccess, SeqAccess, VariantAccess, Visitor,
self, DeserializeSeed, EnumAccess, Error, IgnoredAny, MapAccess, SeqAccess, VariantAccess,
Visitor,
};
use serde::Deserialize;
use std::any::TypeId;
Expand Down Expand Up @@ -322,11 +323,17 @@ impl<'a, 'de> Visitor<'de> for UntypedReflectDeserializerVisitor<'a> {
{
let registration = map
.next_key_seed(TypeRegistrationDeserializer::new(self.registry))?
.ok_or_else(|| Error::invalid_length(0, &"at least one entry"))?;
.ok_or_else(|| Error::invalid_length(0, &"a single entry"))?;

let value = map.next_value_seed(TypedReflectDeserializer {
registration,
registry: self.registry,
})?;

if map.next_key::<IgnoredAny>()?.is_some() {
return Err(Error::invalid_length(2, &"a single entry"));
}

Ok(value)
}
}
Expand Down

0 comments on commit 95c025c

Please sign in to comment.