[Mesa-dev] [PATCH] st/mesa: copy num_immediates field when copying the immediates array

Jose Fonseca jfonseca at vmware.com
Thu Jan 19 09:35:07 PST 2012


I'm not familiar with this code, but looks sensisble to me.

Jose

----- Original Message -----
> Two assignments to num_immediates were missing in
> get_pixel_transfer_visitor() and get_bitmap_visitor().
> The uninitialized value led to valgrind errors and crashes in some
> cases.
> 
> Added new assertions to catch future problems in this area.  Also
> changed num_immediates to unsigned to avoid signed/unsigned
> comparison warnings.
> 
> NOTE: This is a candiate for the 8.0 branch.
> ---
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp |    6 +++++-
>  1 files changed, 5 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 dc841ff..92dffe2 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -357,7 +357,7 @@ public:
>  
>     /** List of immediate_storage */
>     exec_list immediates;
> -   int num_immediates;
> +   unsigned num_immediates;
>  
>     /** List of function_entry */
>     exec_list function_signatures;
> @@ -3645,6 +3645,7 @@ get_pixel_transfer_visitor(struct
> st_fragment_program *fp,
>     v->indirect_addr_temps = original->indirect_addr_temps;
>     v->indirect_addr_consts = original->indirect_addr_consts;
>     memcpy(&v->immediates, &original->immediates,
>     sizeof(v->immediates));
> +   v->num_immediates = original->num_immediates;
>  
>     /*
>      * Get initial pixel color from the texture.
> @@ -3775,6 +3776,7 @@ get_bitmap_visitor(struct st_fragment_program
> *fp,
>     v->indirect_addr_temps = original->indirect_addr_temps;
>     v->indirect_addr_consts = original->indirect_addr_consts;
>     memcpy(&v->immediates, &original->immediates,
>     sizeof(v->immediates));
> +   v->num_immediates = original->num_immediates;
>  
>     /* TEX tmp0, fragment.texcoord[0], texture[0], 2D; */
>     coord = st_src_reg(PROGRAM_INPUT, FRAG_ATTRIB_TEX0,
>     glsl_type::vec2_type);
> @@ -4679,8 +4681,10 @@ st_translate_program(
>     i = 0;
>     foreach_iter(exec_list_iterator, iter, program->immediates) {
>        immediate_storage *imm = (immediate_storage *)iter.get();
> +      assert(i < program->num_immediates);
>        t->immediates[i++] = emit_immediate(t, imm->values, imm->type,
>        imm->size);
>     }
> +   assert(i == program->num_immediates);
>  
>     /* texture samplers */
>     for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
> --
> 1.7.3.4
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 


More information about the mesa-dev mailing list