| Index: mojo/public/rust/src/bindings/macros.rs
|
| diff --git a/mojo/public/rust/src/bindings/macros.rs b/mojo/public/rust/src/bindings/macros.rs
|
| index 62b7274120b8f4b29dd7842b9b8161060376fe1b..bb6f3d22fe33e78e6e6196c1a82d1d7056425efc 100644
|
| --- a/mojo/public/rust/src/bindings/macros.rs
|
| +++ b/mojo/public/rust/src/bindings/macros.rs
|
| @@ -30,12 +30,19 @@ macro_rules! impl_encodable_for_pointer {
|
| }
|
| self.encode_new(encoder, context);
|
| }
|
| - fn decode(decoder: &mut $crate::bindings::decoding::Decoder, context: $crate::bindings::encoding::Context) -> Self {
|
| + fn decode(decoder: &mut $crate::bindings::decoding::Decoder, context: $crate::bindings::encoding::Context) -> Result<Self, ValidationError> {
|
| let ptr = {
|
| let state = decoder.get_mut(&context);
|
| - state.decode_pointer()
|
| + match state.decode_pointer() {
|
| + Some(ptr) => ptr,
|
| + None => return Err(ValidationError::IllegalPointer),
|
| + }
|
| };
|
| - Self::decode_new(decoder, context, ptr)
|
| + if ptr == $crate::bindings::mojom::MOJOM_NULL_POINTER {
|
| + Err(ValidationError::UnexpectedNullPointer)
|
| + } else {
|
| + Self::decode_new(decoder, context, ptr)
|
| + }
|
| }
|
| };
|
| }
|
| @@ -71,7 +78,7 @@ macro_rules! impl_encodable_for_union {
|
| self.inline_encode(encoder, context.set_is_union(true));
|
| }
|
| }
|
| - fn decode(decoder: &mut $crate::bindings::decoding::Decoder, context: $crate::bindings::encoding::Context) -> Self {
|
| + fn decode(decoder: &mut $crate::bindings::decoding::Decoder, context: $crate::bindings::encoding::Context) -> Result<Self, ValidationError> {
|
| if context.is_union() {
|
| Self::nested_decode(decoder, context)
|
| } else {
|
| @@ -111,13 +118,16 @@ macro_rules! impl_encodable_for_interface {
|
| state.encode(pos as i32);
|
| state.encode(Self::version() as u32);
|
| }
|
| - fn decode(decoder: &mut $crate::bindings::decoding::Decoder, context: $crate::bindings::encoding::Context) -> Self {
|
| + fn decode(decoder: &mut $crate::bindings::decoding::Decoder, context: $crate::bindings::encoding::Context) -> Result<Self, ValidationError> {
|
| // TODO(mknyszek): verify version
|
| let (handle_index, _version) = {
|
| let mut state = decoder.get_mut(&context);
|
| (state.decode::<i32>(), state.decode::<u32>())
|
| };
|
| - Self::new(decoder.claim_handle::<$crate::system::message_pipe::MessageEndpoint>(handle_index))
|
| + match decoder.claim_handle::<$crate::system::message_pipe::MessageEndpoint>(handle_index) {
|
| + Ok(handle) => Ok(Self::new(handle)),
|
| + Err(err) => Err(err),
|
| + }
|
| }
|
| }
|
| }
|
|
|