summaryrefslogtreecommitdiff
path: root/generator.py
diff options
context:
space:
mode:
authorDustin Graves <dustin@lunarg.com>2016-04-04 11:14:01 -0600
committerDustin Graves <dustin@lunarg.com>2016-04-04 11:56:29 -0600
commit16ee6bbd953d920c626490f2fc626d06d7325409 (patch)
tree9c64e5a6000da6c8ae213c43f614dd840bec166f /generator.py
parentef1463630a14e773871cb759b168981b07f71825 (diff)
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
Diffstat (limited to 'generator.py')
-rw-r--r--generator.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/generator.py b/generator.py
index 84d7edc1..ebdd024f 100644
--- a/generator.py
+++ b/generator.py
@@ -3372,22 +3372,30 @@ class ParamCheckerOutputGenerator(OutputGenerator):
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)
#