layers: Fix paramcheck struct array NULL indexing
Fixes an issue where the generated parameter_validation code could
index a NULL pointer to an array of structs.
Change-Id: If78f1c97ea256911d857b0b8009b38e6ca6f2581
diff --git a/generator.py b/generator.py
index 84d7edc..ebdd024 100644
--- a/generator.py
+++ b/generator.py
@@ -3372,22 +3372,30 @@
checkExpr += '\n' + indent
if lenParam:
# Need to process all elements in the array
- checkExpr += 'for (uint32_t i = 0; i < {}{}; ++i) {{\n'.format(valuePrefix, lenParam.name)
+ checkExpr += 'if ({}{} != NULL) {{\n'.format(valuePrefix, value.name)
+ indent = self.incIndent(indent)
+ checkExpr += indent + 'for (uint32_t i = 0; i < {}{}; ++i) {{\n'.format(valuePrefix, lenParam.name)
indent = self.incIndent(indent)
checkExpr += indent + 'skipCall |= parameter_validation_{}(report_data, {}, {}, {}, &({}{}[i]));\n'.format(value.type, name, prefix, isInput, valuePrefix, value.name)
indent = self.decIndent(indent)
checkExpr += indent + '}\n'
+ indent = self.decIndent(indent)
+ checkExpr += indent + '}\n'
else:
checkExpr += 'skipCall |= parameter_validation_{}(report_data, {}, {}, {}, {}{});\n'.format(value.type, name, prefix, isInput, valuePrefix, value.name)
else:
# Validation function does not have an isInput field
if lenParam:
# Need to process all elements in the array
- expr = 'for (uint32_t i = 0; i < {}{}; ++i) {{\n'.format(valuePrefix, lenParam.name)
+ expr = 'if ({}{} != NULL) {{\n'.format(valuePrefix, value.name)
+ indent = self.incIndent(indent)
+ expr += indent + 'for (uint32_t i = 0; i < {}{}; ++i) {{\n'.format(valuePrefix, lenParam.name)
indent = self.incIndent(indent)
expr += indent + 'skipCall |= parameter_validation_{}(report_data, {}, {}, &({}{}[i]));\n'.format(value.type, name, prefix, valuePrefix, value.name)
indent = self.decIndent(indent)
expr += indent + '}\n'
+ indent = self.decIndent(indent)
+ expr += indent + '}\n'
else:
expr = 'skipCall |= parameter_validation_{}(report_data, {}, {}, {}{});\n'.format(value.type, name, prefix, valuePrefix, value.name)
#