diff options
author | Eric Engestrom <[email protected]> | 2016-05-31 02:20:12 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2016-05-31 11:46:30 +0200 |
commit | 35fd5282ea39a15fab4f7b9639ffe0853a19b415 (patch) | |
tree | ad62610b70c1f75375368f2cf199444b8e836281 | |
parent | f87352d76966b6e4b0ab5fa9129ccd1ade0c2e7a (diff) |
st/glsl_to_tgsi: prevent infinite loop
`unsigned j` would never fail `j >= 0`, leading to an infinite loop as
`j--` wraps around.
Signed-off-by: Eric Engestrom <[email protected]>
Signed-off-by: Marek Olšák <[email protected]>
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index aa443a556fb..91a0a26de82 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -2447,7 +2447,8 @@ shrink_array_declarations(struct array_decl *arrays, unsigned count, GLbitfield64 double_usage_mask, GLbitfield patch_usage_mask) { - unsigned i, j; + unsigned i; + int j; /* Fix array declarations by removing unused array elements at both ends * of the arrays. For example, mat4[3] where only mat[1] is used. @@ -2456,7 +2457,7 @@ shrink_array_declarations(struct array_decl *arrays, unsigned count, struct array_decl *decl = &arrays[i]; /* Shrink the beginning. */ - for (j = 0; j < decl->array_size; j++) { + for (j = 0; j < (int)decl->array_size; j++) { if (decl->mesa_index >= VARYING_SLOT_PATCH0) { if (patch_usage_mask & BITFIELD64_BIT(decl->mesa_index - VARYING_SLOT_PATCH0 + j)) |