Fixes a Coverity defect by adding checks to see if a value is negative
before using it to index an array. By checking the value first it makes
the code a bit safer but overall should not have a big impact.
CID:
1355598
Signed-off-by: Jakob Sinclair <sinclair.jakob@openmailbox.org>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
const struct util_format_description *desc,
int first_non_void)
{
+ if (first_non_void < 0)
+ return V_008F0C_BUF_DATA_FORMAT_INVALID;
+
unsigned type = desc->channel[first_non_void].type;
int i;
const struct util_format_description *desc,
int first_non_void)
{
- if (desc->format == PIPE_FORMAT_R11G11B10_FLOAT)
+ if (desc->format == PIPE_FORMAT_R11G11B10_FLOAT || first_non_void < 0)
return V_008F0C_BUF_NUM_FORMAT_FLOAT;
switch (desc->channel[first_non_void].type) {