[Mesa-dev] [PATCH] Mesa: fix an error in uniform arrays in row calculating.

Jian Zhao jian.j.zhao at intel.com
Tue Jan 4 18:41:20 PST 2011


Fix the error in uniform row calculating, it may alloc one line
more which may cause out of range on memory usage, sometimes program
aborted when free the memory.
---
 src/mesa/main/uniforms.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index d61856d..ea63dd0 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -511,7 +511,7 @@ get_uniform_rows_cols(const struct gl_program_parameter *p,
          *cols = p->Size;
       }
       else {
-         *rows = p->Size / 4 + 1;
+         *rows = (p->Size + 3) / 4;
          if (p->Size % 4 == 0)
             *cols = 4;
          else
-- 
1.6.0.6



More information about the mesa-dev mailing list