OLD | NEW |
---|---|
1 {%- import "validation_macros.tmpl" as validation_macros %} | 1 {%- import "validation_macros.tmpl" as validation_macros %} |
2 {%- set class_name = struct.name ~ "_Data" %} | 2 {%- set class_name = struct.name ~ "_Data" %} |
3 | 3 |
4 // static | 4 // static |
5 bool {{class_name}}::Validate( | 5 bool {{class_name}}::Validate( |
6 const void* data, | 6 const void* data, |
7 mojo::internal::ValidationContext* validation_context) { | 7 mojo::internal::ValidationContext* validation_context) { |
8 mojo::internal::ValidationContext::ScopedDepthTracker depth_tracker( | |
yzshen1
2016/09/06 17:03:10
This is not the only place: we need to consider th
tibell
2016/09/07 05:41:20
Done.
I was aware of this. The reason I didn't do
| |
9 validation_context); | |
10 if (validation_context->ExceedsMaxDepth()) { | |
11 ReportValidationError( | |
12 validation_context, | |
13 mojo::internal::VALIDATION_ERROR_MAX_RECURSION_DEPTH); | |
14 return false; | |
15 } | |
16 | |
8 if (!data) | 17 if (!data) |
9 return true; | 18 return true; |
10 | 19 |
11 if (!ValidateStructHeaderAndClaimMemory(data, validation_context)) | 20 if (!ValidateStructHeaderAndClaimMemory(data, validation_context)) |
12 return false; | 21 return false; |
13 | 22 |
14 // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if | 23 // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if |
15 // the message comes from an older version. | 24 // the message comes from an older version. |
16 const {{class_name}}* object = static_cast<const {{class_name}}*>(data); | 25 const {{class_name}}* object = static_cast<const {{class_name}}*>(data); |
17 | 26 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 return true; | 70 return true; |
62 {%- endif %} | 71 {%- endif %} |
63 {%- set field_expr = "object->" ~ packed_field.field.name %} | 72 {%- set field_expr = "object->" ~ packed_field.field.name %} |
64 {{validation_macros.validate_field(packed_field.field, field_expr, struct.name, true)}} | 73 {{validation_macros.validate_field(packed_field.field, field_expr, struct.name, true)}} |
65 {%- endif %} | 74 {%- endif %} |
66 {%- endfor %} | 75 {%- endfor %} |
67 | 76 |
68 return true; | 77 return true; |
69 } | 78 } |
70 | 79 |
OLD | NEW |