From: Dustin Graves Date: Mon, 4 Apr 2016 17:14:01 +0000 (-0600) Subject: layers: Fix paramcheck struct array NULL indexing X-Git-Tag: submit/tizen/20181227.054638~3401 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f778c5c25847a6e819902af9d60b9921bba3bd0f;p=platform%2Fupstream%2FVulkan-Tools.git 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 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) #