From: Eric Engestrom Date: Tue, 31 May 2016 01:20:12 +0000 (+0100) Subject: st/glsl_to_tgsi: prevent infinite loop X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=35fd5282ea39a15fab4f7b9639ffe0853a19b415;p=mesa.git 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 Signed-off-by: Marek Olšák --- 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))