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

Ian Romanick idr at freedesktop.org
Mon Apr 22 21:17:05 PDT 2013


On 04/23/2013 02:39 AM, Kenneth Graunke wrote:
> 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.

This *CANNOT* be the right fix.  This just papers over things.  There 
are a lot of entries in the table that are not initialized when several 
similar entries are initialized.  For example, *ONE* of the ETC2 entries 
is missing.  Many of the integer formats are present, but some are 
missing.  Etc.

> 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;
>



More information about the mesa-dev mailing list