[Mesa-dev] [PATCH] mesa: memset get_unpack_rgba_function's format table to 0.

Kenneth Graunke kenneth at whitecape.org
Mon Apr 22 17:39:42 PDT 2013


Otherwise, the table could be full of uninitialized garbage.  That means
the NULL check at the bottom might not happen, so we wouldn't get the
_mesa_problem, and we'd then return garbage.

format_pack.c also has tables like this and memsets them.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/main/format_unpack.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index 0933b4e..7206d25 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -1730,6 +1730,8 @@ get_unpack_rgba_function(gl_format format)
    static GLboolean initialized = GL_FALSE;
 
    if (!initialized) {
+      memset(table, 0, sizeof(table));
+
       table[MESA_FORMAT_NONE] = NULL;
 
       table[MESA_FORMAT_RGBA8888] = unpack_RGBA8888;
-- 
1.8.2.1



More information about the mesa-dev mailing list