diff options
author | Ilia Mirkin <imirkin@alum.mit.edu> | 2016-03-06 12:19:04 -0500 |
---|---|---|
committer | Emil Velikov <emil.l.velikov@gmail.com> | 2016-04-11 21:02:17 +0100 |
commit | 9bfc47358d4c72f54d2f686498d37beb105f216a (patch) | |
tree | c2a9f815393c9f9ba92a2b7afad919723e6afc78 | |
parent | b2ac03a8fc91953aa6a4fccbcd7aa5ef447e0736 (diff) |
glsl: avoid stack smashing when there are too many attributes
This fixes a crash in
dEQP-GLES3.functional.transform_feedback.array_element.separate.points.lowp_mat3x2
and likely others. The vertex shader has > 16 input variables (without
explicit locations), which causes us to index outside of the to_assign
array.
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Cc: "11.1 11.2" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit f6827e20d12ab062440bc809b8f2338b68edac45)
-rw-r--r-- | src/glsl/linker.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 200a0afffce..30289319c62 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -2627,6 +2627,13 @@ assign_attribute_or_color_locations(gl_shader_program *prog, continue; } + if (num_attr >= ARRAY_SIZE(to_assign)) { + linker_error(prog, "too many %s (max %u)", + target_index == MESA_SHADER_VERTEX ? + "vertex shader inputs" : "fragment shader outputs", + (unsigned)ARRAY_SIZE(to_assign)); + return false; + } to_assign[num_attr].slots = slots; to_assign[num_attr].var = var; num_attr++; |