Thanks, Eric. This patch is
Reviewed-by: Caio Marcelo de Oliveira Filho
On Thu, Aug 23, 2018 at 03:23:55PM +0100, Eric Engestrom wrote:
> It doesn't happen anywhere right now, but a caller could say it doesn't
> want the source, only its size, and in that case we would just leak that
> memory.
> Let's only actually allocate it when the caller wants it and will take
> ownership of that memory.
>
> Suggested-by: Caio Marcelo de Oliveira Filho
> Signed-off-by: Eric Engestrom
> ---
> tests/util/piglit-shader-test.c | 9 -
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/tests/util/piglit-shader-test.c b/tests/util/piglit-shader-test.c
> index 4802983e56d1037be079..f11ee8ab5383080ae090 100644
> --- a/tests/util/piglit-shader-test.c
> +++ b/tests/util/piglit-shader-test.c
> @@ -101,7 +101,6 @@ piglit_load_source_from_shader_test(const char *filename,
> unsigned *output_source_size)
> {
> char group_name[4096];
> - char *source = NULL;
> unsigned text_size;
> char *line = NULL;
> char *first_line = NULL;
> @@ -142,11 +141,11 @@ piglit_load_source_from_shader_test(const char
> *filename,
> }
>
> text_size = line - first_line + 1;
> - source = malloc(sizeof(char*) * text_size);
> - snprintf(source, line - first_line + 1, "%s", first_line);
>
> - if (output_source)
> - *output_source = source;
> + if (output_source) {
> + *output_source = malloc(sizeof(char*) * text_size);
> + snprintf(*output_source, line - first_line + 1, "%s",
> first_line);
> + }
>
> if (output_source_size)
> *output_source_size = text_size;
> --
> Cheers,
> Eric
>
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit