[Cogl] [PATCH] Fix a clear of an array allocated with alloca which had the wrong size

Robert Bragg robert at sixbynine.org
Thu Feb 7 13:59:39 PST 2013


This looks good to land to me:

Reviewed-by: Robert Bragg <robert at linux.intel.com>

thanks,
- Robert

On Wed, Feb 6, 2013 at 1:03 PM, Neil Roberts <neil at linux.intel.com> wrote:
> The array allocated for storing the difference flags for each layer in
> cogl-pipeline-opengl.c was being cleared with the size of a pointer
> instead of the size actually allocated for the array. Presumably this
> would mean that if there is more than one layer it wouldn't clear the
> array properly.
>
> Also the size of the array was slightly wrong because it was allocating
> the size of a pointer for each layer instead of the size of an
> unsigned long.
>
> This was originally reported by Jasper St. Pierre on #clutter.
> ---
>  cogl/driver/gl/cogl-pipeline-opengl.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/driver/gl/cogl-pipeline-opengl.c
> index 0a7b4db..e4d2976 100644
> --- a/cogl/driver/gl/cogl-pipeline-opengl.c
> +++ b/cogl/driver/gl/cogl-pipeline-opengl.c
> @@ -1173,8 +1173,8 @@ _cogl_pipeline_flush_gl_state (CoglPipeline *pipeline,
>    if (n_layers)
>      {
>        CoglPipelineCompareLayersState state;
> -      layer_differences = g_alloca (sizeof (unsigned long *) * n_layers);
> -      memset (layer_differences, 0, sizeof (layer_differences));
> +      layer_differences = g_alloca (sizeof (unsigned long) * n_layers);
> +      memset (layer_differences, 0, sizeof (unsigned long) * n_layers);
>        state.i = 0;
>        state.layer_differences = layer_differences;
>        _cogl_pipeline_foreach_layer_internal (pipeline,
> --
> 1.7.11.3.g3c3efa5
>
> _______________________________________________
> Cogl mailing list
> Cogl at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/cogl


More information about the Cogl mailing list