mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 17:30:12 +01:00
glsl: Fix (and validate) comment above glsl_type::name.
The comment above glsl_type::name claimed that it could sometimes be NULL. This was wrong--it is never NULL. Many error handling paths would segfault if it were. (Anonymous structs are assigned names like "#anon_struct_0001"--see the ast_struct_specifier constructor in glsl_parser_extras.cpp.) Fix the comment and add assertions to validate that it really is never NULL. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
parent
5b2855bfe7
commit
5b0bd8ece8
2 changed files with 5 additions and 2 deletions
|
|
@ -57,6 +57,7 @@ glsl_type::glsl_type(GLenum gl_type,
|
|||
length(0)
|
||||
{
|
||||
init_ralloc_type_ctx();
|
||||
assert(name != NULL);
|
||||
this->name = ralloc_strdup(this->mem_ctx, name);
|
||||
/* Neither dimension is zero or both dimensions are zero.
|
||||
*/
|
||||
|
|
@ -75,6 +76,7 @@ glsl_type::glsl_type(GLenum gl_type,
|
|||
length(0)
|
||||
{
|
||||
init_ralloc_type_ctx();
|
||||
assert(name != NULL);
|
||||
this->name = ralloc_strdup(this->mem_ctx, name);
|
||||
memset(& fields, 0, sizeof(fields));
|
||||
}
|
||||
|
|
@ -91,6 +93,7 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
|
|||
unsigned int i;
|
||||
|
||||
init_ralloc_type_ctx();
|
||||
assert(name != NULL);
|
||||
this->name = ralloc_strdup(this->mem_ctx, name);
|
||||
this->fields.structure = ralloc_array(this->mem_ctx,
|
||||
glsl_struct_field, length);
|
||||
|
|
@ -114,6 +117,7 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
|
|||
unsigned int i;
|
||||
|
||||
init_ralloc_type_ctx();
|
||||
assert(name != NULL);
|
||||
this->name = ralloc_strdup(this->mem_ctx, name);
|
||||
this->fields.structure = ralloc_array(this->mem_ctx,
|
||||
glsl_struct_field, length);
|
||||
|
|
|
|||
|
|
@ -132,8 +132,7 @@ struct glsl_type {
|
|||
/**
|
||||
* Name of the data type
|
||||
*
|
||||
* This may be \c NULL for anonymous structures, for arrays, or for
|
||||
* function types.
|
||||
* Will never be \c NULL.
|
||||
*/
|
||||
const char *name;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue