aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorJakob Sinclair <[email protected]>2016-04-25 09:03:52 +0200
committerMarek Olšák <[email protected]>2016-04-28 11:33:38 +0200
commit76b8c5cc602eda19c91b842b02f84564c18e79a6 (patch)
tree0b4a6b78863a780c2f6ead5cea1789aa4cb30148 /src/gallium/drivers
parent860210ccfc0a90a4635fc930cd323bc426db5991 (diff)
radeonsi: check if value is negative
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 <[email protected]> Signed-off-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/radeonsi/si_state.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index 06798f2ac60..c214932e28b 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -1762,6 +1762,9 @@ static uint32_t si_translate_buffer_dataformat(struct pipe_screen *screen,
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;
@@ -1836,7 +1839,7 @@ static uint32_t si_translate_buffer_numformat(struct pipe_screen *screen,
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) {