Index: mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl |
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl |
index 3471932b6818d57bc872b80797486be1e731527d..73f6c95865fb763d5c2f25440c85fbbae7fb448b 100644 |
--- a/mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl |
+++ b/mojo/public/tools/bindings/generators/cpp_templates/union_serialization_definition.tmpl |
@@ -93,9 +93,10 @@ void SerializeUnion_({{union.name}}Ptr input, mojo::internal::Buffer* buf, |
*output = result; |
} |
-void Deserialize_(internal::{{union.name}}_Data* input, |
+bool Deserialize_(internal::{{union.name}}_Data* input, |
{{union.name}}Ptr* output, |
mojo::internal::SerializationContext* context) { |
+ bool success = true; |
if (input && !input->is_null()) { |
{{union.name}}Ptr result({{union.name}}::New()); |
mojo::internal::UnionAccessor<{{union.name}}> result_acc(result.get()); |
@@ -104,7 +105,8 @@ void Deserialize_(internal::{{union.name}}_Data* input, |
case {{union.name}}::Tag::{{field.name|upper}}: { |
{% if field.kind|is_object_kind %} |
result_acc.SwitchActive({{union.name}}::Tag::{{field.name|upper}}); |
- Deserialize_(input->data.f_{{field.name}}.ptr, result_acc.data()->{{field.name}}, context); |
+ if (!Deserialize_(input->data.f_{{field.name}}.ptr, result_acc.data()->{{field.name}}, context)) |
+ success = false; |
{% elif field.kind|is_any_handle_kind %} |
{{field.kind|cpp_wrapper_type}}* {{field.name}} = |
reinterpret_cast<{{field.kind|cpp_wrapper_type}}*>(&input->data.f_{{field.name}}); |
@@ -132,4 +134,5 @@ void Deserialize_(internal::{{union.name}}_Data* input, |
} else { |
output->reset(); |
} |
+ return success; |
} |