Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Unified Diff: mojo/public/cpp/bindings/lib/map_serialization.h

Issue 2036623002: Validate map keys in C++ Mojo bindings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/cpp/bindings/lib/map_data_internal.h ('k') | mojo/public/cpp/bindings/lib/validate_params.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/lib/map_serialization.h
diff --git a/mojo/public/cpp/bindings/lib/map_serialization.h b/mojo/public/cpp/bindings/lib/map_serialization.h
index 91e404e478abe9518e6790da88073fa4c70cc4c1..60b6364fb4a310a7d2b667ff9657dec996d972f5 100644
--- a/mojo/public/cpp/bindings/lib/map_serialization.h
+++ b/mojo/public/cpp/bindings/lib/map_serialization.h
@@ -113,8 +113,10 @@ struct Serializer<Map<Key, Value>, MaybeConstUserType> {
static void Serialize(MaybeConstUserType& input,
Buffer* buf,
Data** output,
- const ArrayValidateParams* value_validate_params,
+ const ArrayValidateParams* validate_params,
SerializationContext* context) {
+ DCHECK(validate_params->key_validate_params);
+ DCHECK(validate_params->element_validate_params);
if (CallIsNullIfExists<Traits>(input)) {
*output = nullptr;
return;
@@ -124,21 +126,19 @@ struct Serializer<Map<Key, Value>, MaybeConstUserType> {
if (result) {
result->keys.ptr = Array<Key>::Data_::New(Traits::GetSize(input), buf);
if (result->keys.ptr) {
- const ArrayValidateParams* key_validate_params =
- MapKeyValidateParamsFactory<
- typename GetDataTypeAsArrayElement<Key>::Data>::Get();
MapKeyReader<MaybeConstUserType> key_reader(input);
KeyArraySerializer::SerializeElements(
- &key_reader, buf, result->keys.ptr, key_validate_params, context);
+ &key_reader, buf, result->keys.ptr,
+ validate_params->key_validate_params, context);
}
result->values.ptr =
Array<Value>::Data_::New(Traits::GetSize(input), buf);
if (result->values.ptr) {
MapValueReader<MaybeConstUserType> value_reader(input);
- ValueArraySerializer::SerializeElements(&value_reader, buf,
- result->values.ptr,
- value_validate_params, context);
+ ValueArraySerializer::SerializeElements(
+ &value_reader, buf, result->values.ptr,
+ validate_params->element_validate_params, context);
}
}
*output = result;
« no previous file with comments | « mojo/public/cpp/bindings/lib/map_data_internal.h ('k') | mojo/public/cpp/bindings/lib/validate_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698