[Mesa-dev] [PATCH 2/7] [RFC] glsl: Fix reading of uninitialized memory
Ian Romanick
idr at freedesktop.org
Tue Jun 7 17:27:54 UTC 2016
On 06/07/2016 07:26 AM, Juha-Pekka Heikkila wrote:
> Switch to use memory allocations which zero memory for places
> where needed.
This series is in backwards order. Assuming that rzalloc and friends
are necessary in these places, if a git-bisect hits the previous patch,
a person will (potentially) observer spurious failures.
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> ---
> src/compiler/glsl/ast_to_hir.cpp | 2 +-
> src/compiler/glsl/glcpp/glcpp-parse.y | 4 ++--
> src/compiler/glsl/link_uniform_blocks.cpp | 2 +-
> src/compiler/glsl_types.cpp | 2 +-
> 4 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
> index b7192b2..4fb2809 100644
> --- a/src/compiler/glsl/ast_to_hir.cpp
> +++ b/src/compiler/glsl/ast_to_hir.cpp
> @@ -6518,7 +6518,7 @@ ast_process_struct_or_iface_block_members(exec_list *instructions,
> * the types to HIR. This ensures that structure definitions embedded in
> * other structure definitions or in interface blocks are processed.
> */
> - glsl_struct_field *const fields = ralloc_array(state, glsl_struct_field,
> + glsl_struct_field *const fields = rzalloc_array(state, glsl_struct_field,
> decl_count);
>
> bool first_member = true;
> diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y b/src/compiler/glsl/glcpp/glcpp-parse.y
> index 2cfa6a6..b3565b5 100644
> --- a/src/compiler/glsl/glcpp/glcpp-parse.y
> +++ b/src/compiler/glsl/glcpp/glcpp-parse.y
> @@ -1315,7 +1315,7 @@ glcpp_parser_create(const struct gl_extensions *extensions, gl_api api)
> {
> glcpp_parser_t *parser;
>
> - parser = ralloc (NULL, glcpp_parser_t);
> + parser = rzalloc (NULL, glcpp_parser_t);
>
> glcpp_lex_init_extra (parser, &parser->scanner);
> parser->defines = hash_table_ctor(32, hash_table_string_hash,
> @@ -1855,7 +1855,7 @@ _parser_active_list_push(glcpp_parser_t *parser, const char *identifier,
> {
> active_list_t *node;
>
> - node = ralloc(parser->active, active_list_t);
> + node = rzalloc(parser->active, active_list_t);
> node->identifier = ralloc_strdup(node, identifier);
> node->marker = marker;
> node->next = parser->active;
> diff --git a/src/compiler/glsl/link_uniform_blocks.cpp b/src/compiler/glsl/link_uniform_blocks.cpp
> index b816dab..0a0c886 100644
> --- a/src/compiler/glsl/link_uniform_blocks.cpp
> +++ b/src/compiler/glsl/link_uniform_blocks.cpp
> @@ -315,7 +315,7 @@ create_buffer_blocks(void *mem_ctx, struct gl_context *ctx,
> /* Allocate storage to hold all of the information related to uniform
> * blocks that can be queried through the API.
> */
> - struct gl_uniform_block *blocks = ralloc_array(mem_ctx, gl_uniform_block, num_blocks);
> + struct gl_uniform_block *blocks = rzalloc_array(mem_ctx, gl_uniform_block, num_blocks);
> gl_uniform_buffer_variable *variables =
> ralloc_array(blocks, gl_uniform_buffer_variable, num_variables);
>
> diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
> index 11f1e85..613c449 100644
> --- a/src/compiler/glsl_types.cpp
> +++ b/src/compiler/glsl_types.cpp
> @@ -157,7 +157,7 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
> init_ralloc_type_ctx();
> assert(name != NULL);
> this->name = ralloc_strdup(this->mem_ctx, name);
> - this->fields.structure = ralloc_array(this->mem_ctx,
> + this->fields.structure = rzalloc_array(this->mem_ctx,
> glsl_struct_field, length);
> for (i = 0; i < length; i++) {
> this->fields.structure[i].type = fields[i].type;
>
More information about the mesa-dev
mailing list