[Piglit] [PATCH] arb_uniform_buffer_object: Fix use after free.

Brian Paul brianp at vmware.com
Thu Nov 29 07:35:26 PST 2012


On 11/28/2012 11:55 PM, Vinson Lee wrote:
> Fixes use after free defect reported by Coverity.
>
> Signed-off-by: Vinson Lee<vlee at freedesktop.org>
> ---
>   .../spec/arb_uniform_buffer_object/getactiveuniformsiv-uniform-type.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/tests/spec/arb_uniform_buffer_object/getactiveuniformsiv-uniform-type.c b/tests/spec/arb_uniform_buffer_object/getactiveuniformsiv-uniform-type.c
> index bd595ae..f15a41e 100644
> --- a/tests/spec/arb_uniform_buffer_object/getactiveuniformsiv-uniform-type.c
> +++ b/tests/spec/arb_uniform_buffer_object/getactiveuniformsiv-uniform-type.c
> @@ -63,11 +63,13 @@ test_format(const struct uniform_type *type)
>
>   	asprintf(&fs_source, fs_template, type->type);
>   	fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source);
> -	free(fs_source);
>   	prog = piglit_link_simple_program(0, fs);
>   	if (!fs || !prog) {
>   		fprintf(stderr, "Failed to compile shader:\n%s", fs_source);
> +		free(fs_source);
>   		piglit_report_result(PIGLIT_FAIL);
> +	} else {
> +		free(fs_source);
>   	}
>
>   	glGetUniformIndices(prog, 1,&uniform_name,&uniform_index);

A simpler solution would be to simply call free() after the 
conditional (I don't think anyone's too worried about freeing 
memory/etc when we call piglit_report_result() and exit).  But this is OK.

Reviewed-by: Brian Paul <brianp at vmware.com>


More information about the Piglit mailing list