[1/4] fbo-drawbuffers-maxtargets: fix a warning

Submitted by Nicolai Hähnle on Sept. 13, 2018, 6:10 p.m.

Details

Message ID 20180913181049.16397-2-nhaehnle@gmail.com
State New
Headers show
Series "Autumn cleaning: misc test case additions and fixes" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Nicolai Hähnle Sept. 13, 2018, 6:10 p.m.
From: Nicolai Hähnle <nicolai.haehnle@amd.com>

Ensure that the allocated buffer is guaranteed to be big enough.
---
 tests/fbo/fbo-drawbuffers-maxtargets.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/tests/fbo/fbo-drawbuffers-maxtargets.c b/tests/fbo/fbo-drawbuffers-maxtargets.c
index f5e2a48ed..5d5a09f62 100644
--- a/tests/fbo/fbo-drawbuffers-maxtargets.c
+++ b/tests/fbo/fbo-drawbuffers-maxtargets.c
@@ -137,21 +137,21 @@  generate_and_display_drawbuffers(int count)
 
 	glDrawBuffersARB(count, attachments);
 
 	/* Clear all to red so we see if the shader rendering happens. */
 	glClearColor(1.0, 0.0, 0.0, 0.0);
 	glClear(GL_COLOR_BUFFER_BIT);
 
 	/* Build the shader that writes different color to each buffer. */
 	vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
 
-	fs_count_source = malloc(strlen(fs_source) + 5);
+	fs_count_source = malloc(strlen(fs_source) + 10);
 	sprintf(fs_count_source, fs_source, count);
 	fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_count_source);
 	free(fs_count_source);
 
 	prog = piglit_link_simple_program(vs, fs);
 	glUseProgram(prog);
 
 	if (!piglit_check_gl_error(GL_NO_ERROR))
 		piglit_report_result(PIGLIT_FAIL);
 

Comments

On 14/9/18 4:10 am, Nicolai Hähnle wrote:
> From: Nicolai Hähnle <nicolai.haehnle@amd.com>
> 
> Ensure that the allocated buffer is guaranteed to be big enough.
> ---
>   tests/fbo/fbo-drawbuffers-maxtargets.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/fbo/fbo-drawbuffers-maxtargets.c b/tests/fbo/fbo-drawbuffers-maxtargets.c
> index f5e2a48ed..5d5a09f62 100644
> --- a/tests/fbo/fbo-drawbuffers-maxtargets.c
> +++ b/tests/fbo/fbo-drawbuffers-maxtargets.c
> @@ -137,21 +137,21 @@ generate_and_display_drawbuffers(int count)
>   
>   	glDrawBuffersARB(count, attachments);
>   
>   	/* Clear all to red so we see if the shader rendering happens. */
>   	glClearColor(1.0, 0.0, 0.0, 0.0);
>   	glClear(GL_COLOR_BUFFER_BIT);
>   
>   	/* Build the shader that writes different color to each buffer. */
>   	vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
>   
> -	fs_count_source = malloc(strlen(fs_source) + 5);
> +	fs_count_source = malloc(strlen(fs_source) + 10);

max_targets is clamped to 16 so it's not really needed is it?

I guess it won't hurt though.

Acked-by: Timothy Arceri <tarceri@itsqueeze.com>

>   	sprintf(fs_count_source, fs_source, count);
>   	fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_count_source);
>   	free(fs_count_source);
>   
>   	prog = piglit_link_simple_program(vs, fs);
>   	glUseProgram(prog);
>   
>   	if (!piglit_check_gl_error(GL_NO_ERROR))
>   		piglit_report_result(PIGLIT_FAIL);
>   
>