Re: [Piglit] [PATCH piglit] util: stop overallocating shader memory

2018-08-24 Thread Alejandro Piñeiro
Reviewed-by: Alejandro Piñeiro 


On 23/08/18 18:50, Eric Engestrom wrote:
> Fixes: 606e40b2659ad7fc4ae8e "util: Add utilities to handle shader_test files"
> Cc: Alejandro Piñeiro 
> Signed-off-by: Eric Engestrom 
> ---
>  tests/util/piglit-shader-test.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/util/piglit-shader-test.c b/tests/util/piglit-shader-test.c
> index f11ee8ab5383080ae090..1db6aa2eb203a50ca93e 100644
> --- a/tests/util/piglit-shader-test.c
> +++ b/tests/util/piglit-shader-test.c
> @@ -143,7 +143,7 @@ piglit_load_source_from_shader_test(const char *filename,
>   text_size = line - first_line + 1;
>  
>   if (output_source) {
> - *output_source = malloc(sizeof(char*) * text_size);
> + *output_source = malloc(sizeof(char) * text_size);
>   snprintf(*output_source, line - first_line + 1, "%s", 
> first_line);
>   }
>  

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH piglit] util: stop overallocating shader memory

2018-08-23 Thread Caio Marcelo de Oliveira Filho
On Thu, Aug 23, 2018 at 05:50:44PM +0100, Eric Engestrom wrote:
> Fixes: 606e40b2659ad7fc4ae8e "util: Add utilities to handle shader_test files"
> Cc: Alejandro Piñeiro 
> Signed-off-by: Eric Engestrom 
> ---
>  tests/util/piglit-shader-test.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/util/piglit-shader-test.c b/tests/util/piglit-shader-test.c
> index f11ee8ab5383080ae090..1db6aa2eb203a50ca93e 100644
> --- a/tests/util/piglit-shader-test.c
> +++ b/tests/util/piglit-shader-test.c
> @@ -143,7 +143,7 @@ piglit_load_source_from_shader_test(const char *filename,
>   text_size = line - first_line + 1;
>  
>   if (output_source) {
> - *output_source = malloc(sizeof(char*) * text_size);
> + *output_source = malloc(sizeof(char) * text_size);
>   snprintf(*output_source, line - first_line + 1, "%s", 
> first_line);

Also could reuse text_size here too.  And I wonder if at this point,
we could just call strndup with 'text_size - 1'.  Haven't looked
deeply but we might also have a off-by-one lurking with this text_size
being returned.


Thanks,
Caio
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH piglit] util: stop overallocating shader memory

2018-08-23 Thread Caio Marcelo de Oliveira Filho
On Thu, Aug 23, 2018 at 05:50:44PM +0100, Eric Engestrom wrote:
> Fixes: 606e40b2659ad7fc4ae8e "util: Add utilities to handle shader_test files"
> Cc: Alejandro Piñeiro 
> Signed-off-by: Eric Engestrom 
> ---
>  tests/util/piglit-shader-test.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/util/piglit-shader-test.c b/tests/util/piglit-shader-test.c
> index f11ee8ab5383080ae090..1db6aa2eb203a50ca93e 100644
> --- a/tests/util/piglit-shader-test.c
> +++ b/tests/util/piglit-shader-test.c
> @@ -143,7 +143,7 @@ piglit_load_source_from_shader_test(const char *filename,
>   text_size = line - first_line + 1;
>  
>   if (output_source) {
> - *output_source = malloc(sizeof(char*) * text_size);
> + *output_source = malloc(sizeof(char) * text_size);
>   snprintf(*output_source, line - first_line + 1, "%s", 
> first_line);
>   }

Good catch.

Reviewed-by: Caio Marcelo de Oliveira Filho 

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH piglit] util: stop overallocating shader memory

2018-08-23 Thread Eric Engestrom
Fixes: 606e40b2659ad7fc4ae8e "util: Add utilities to handle shader_test files"
Cc: Alejandro Piñeiro 
Signed-off-by: Eric Engestrom 
---
 tests/util/piglit-shader-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/util/piglit-shader-test.c b/tests/util/piglit-shader-test.c
index f11ee8ab5383080ae090..1db6aa2eb203a50ca93e 100644
--- a/tests/util/piglit-shader-test.c
+++ b/tests/util/piglit-shader-test.c
@@ -143,7 +143,7 @@ piglit_load_source_from_shader_test(const char *filename,
text_size = line - first_line + 1;
 
if (output_source) {
-   *output_source = malloc(sizeof(char*) * text_size);
+   *output_source = malloc(sizeof(char) * text_size);
snprintf(*output_source, line - first_line + 1, "%s", 
first_line);
}
 
-- 
Cheers,
  Eric

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit