summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>2016-04-28 21:09:12 +0200
committerEmil Velikov <emil.l.velikov@gmail.com>2016-05-05 11:47:53 +0100
commit970941fa86fe763212ad64d5a99ea90fd40457cb (patch)
tree44d395d2139b9970153afe685b83fce948651753
parent7cd7d194228f992c5a1a70d16c907ff2a9511a71 (diff)
st/glsl_to_tgsi: fix potential crash when allocating temporaries
When index - t->temps_size is greater than 4096, allocating space for temporaries on demand will miserably crash. This can happen when a game uses a lot of temporaries like the recent released Tomb raider. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com> Cc: "11.1 11.2" <mesa-stable@lists.freedesktop.org> (cherry picked from commit 8f2238ccbae399a20fce24c5941accced7cee8d2)
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 57daec946c4..4c433cdab8a 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -4526,7 +4526,7 @@ dst_register(struct st_translate *t, gl_register_file file, unsigned index,
case PROGRAM_TEMPORARY:
/* Allocate space for temporaries on demand. */
if (index >= t->temps_size) {
- const int inc = 4096;
+ const int inc = align(index - t->temps_size + 1, 4096);
t->temps = (struct ureg_dst*)
realloc(t->temps,