Index: mojo/public/cpp/bindings/lib/array_serialization.h |
diff --git a/mojo/public/cpp/bindings/lib/array_serialization.h b/mojo/public/cpp/bindings/lib/array_serialization.h |
index db5fb099f0b93a346f8c100287c78878399dae75..fd2ebb3efe24843d70a0c6c2ba2e02e4b6984f6a 100644 |
--- a/mojo/public/cpp/bindings/lib/array_serialization.h |
+++ b/mojo/public/cpp/bindings/lib/array_serialization.h |
@@ -300,8 +300,10 @@ struct ArraySerializer< |
static size_t GetSerializedSize(const Array<S>& input) { |
size_t size = sizeof(Array_Data<S_Data*>) + |
input.size() * sizeof(StructPointer<S_Data>); |
- for (size_t i = 0; i < input.size(); ++i) |
- size += GetSerializedSize_(*(UnwrapConstStructPtr<S>::value(input[i]))); |
+ for (size_t i = 0; i < input.size(); ++i) { |
+ if (!input[i].is_null()) |
+ size += GetSerializedSize_(*(UnwrapConstStructPtr<S>::value(input[i]))); |
+ } |
return size; |
} |
@@ -406,15 +408,19 @@ struct ArraySerializer< |
template <typename T> |
static void Run(typename WrapperTraits<StructPtr<T>>::DataType input, |
StructPtr<T>* output) { |
- *output = T::New(); |
- Deserialize_(input, output->get()); |
+ if (input != nullptr) { |
viettrungluu
2015/12/07 22:03:51
nit: probably "if (input)" should be fine and more
vardhan
2015/12/07 22:48:31
Done.
I was trying to be more explicit about what
|
+ *output = T::New(); |
+ Deserialize_(input, output->get()); |
+ } |
} |
template <typename T> |
static void Run(typename WrapperTraits<InlinedStructPtr<T>>::DataType input, |
InlinedStructPtr<T>* output) { |
- *output = T::New(); |
- Deserialize_(input, output->get()); |
+ if (input != nullptr) { |
viettrungluu
2015/12/07 22:03:51
"
vardhan
2015/12/07 22:48:31
Done.
|
+ *output = T::New(); |
+ Deserialize_(input, output->get()); |
+ } |
} |
}; |
}; |
@@ -477,7 +483,7 @@ template <typename E> |
inline size_t GetSerializedSize_(const Array<E>& input) { |
if (!input) |
return 0; |
- typedef typename internal::WrapperTraits<E>::DataType F; |
+ using F = typename internal::WrapperTraits<E>::DataType; |
return internal::ArraySerializer<E, F>::GetSerializedSize(input); |
} |