Mesa (master): rgtc: don't try to access off the end of the block.

Dave Airlie airlied at kemper.freedesktop.org
Wed Mar 2 03:10:07 UTC 2011


Module: Mesa
Branch: master
Commit: 521394a204bd8073846acc7f9861081d29fa24c9
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=521394a204bd8073846acc7f9861081d29fa24c9

Author: Dave Airlie <airlied at redhat.com>
Date:   Wed Mar  2 13:14:34 2011 +1000

rgtc: don't try to access off the end of the block.

if the values are all in the last dword, the high bits can be 0,

This fixes a valgrind warning I saw when playing with mipmaps.

Signed-off-by: Dave Airlie <airlied at redhat.com>

---

 src/mesa/main/texcompress_rgtc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/texcompress_rgtc.c b/src/mesa/main/texcompress_rgtc.c
index ebdaaf4..6b4e3b1 100644
--- a/src/mesa/main/texcompress_rgtc.c
+++ b/src/mesa/main/texcompress_rgtc.c
@@ -321,7 +321,7 @@ static void _fetch_texel_rgtc_u(GLint srcRowStride, const GLubyte *pixdata,
    const GLubyte alpha1 = blksrc[1];
    const GLubyte bit_pos = ((j&3) * 4 + (i&3)) * 3;
    const GLubyte acodelow = blksrc[2 + bit_pos / 8];
-   const GLubyte acodehigh = blksrc[3 + bit_pos / 8];
+   const uint8_t acodehigh = (3 + bit_pos / 8) < 8 ? blksrc[3 + bit_pos / 8] : 0;
    const GLubyte code = (acodelow >> (bit_pos & 0x7) |
       (acodehigh  << (8 - (bit_pos & 0x7)))) & 0x7;
 
@@ -351,7 +351,7 @@ static void _fetch_texel_rgtc_s(GLint srcRowStride, const GLbyte *pixdata,
    const GLbyte alpha1 = blksrc[1];
    const GLbyte bit_pos = ((j&3) * 4 + (i&3)) * 3;
    const GLbyte acodelow = blksrc[2 + bit_pos / 8];
-   const GLbyte acodehigh = blksrc[3 + bit_pos / 8];
+   const uint8_t acodehigh = (3 + bit_pos / 8) < 8 ? blksrc[3 + bit_pos / 8] : 0;
    const GLbyte code = (acodelow >> (bit_pos & 0x7) |
       (acodehigh  << (8 - (bit_pos & 0x7)))) & 0x7;
 




More information about the mesa-commit mailing list