[Piglit] [PATCH] GL_ARB_ubo/maxblocks: fix writing to zero-length string

Anuj Phogat anuj.phogat at gmail.com
Thu Aug 2 13:59:05 PDT 2012


On Thu, Aug 2, 2012 at 9:04 AM, Brian Paul <brianp at vmware.com> wrote:
> When get_shader() was called with blocks=0 we were allocating string
> buffers of length zero.  Assigning prefix[0] = 0 caused an invalid
> memory write (found w/ valgrind).  Adding one to the calloc() length
> fixes this.
>
> But compiling a shader string of length=0 seems a little strange...
> ---
>  tests/spec/arb_uniform_buffer_object/maxblocks.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tests/spec/arb_uniform_buffer_object/maxblocks.c b/tests/spec/arb_uniform_buffer_object/maxblocks.c
> index 6f67b59..b28cc2d 100644
> --- a/tests/spec/arb_uniform_buffer_object/maxblocks.c
> +++ b/tests/spec/arb_uniform_buffer_object/maxblocks.c
> @@ -87,9 +87,9 @@ get_shader(GLenum target, const char *block_prefix, int blocks)
>         int i;
>
>         prefix = calloc(1, (strlen(block_prefix) * 2 + strlen(prefix_template) +
> -                           20) * blocks);
> +                           20) * blocks + 1);
>         body = calloc(1, (strlen(block_prefix) + strlen(body_template) +
> -                         20) * blocks);
> +                         20) * blocks + 1);
>         prefix_tail = prefix;
>         prefix[0] = 0;
>         body_tail = body;
> --
> 1.7.3.4
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit

Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>


More information about the Piglit mailing list