[Mesa-dev] [PATCH] glsl: Guard against NULL dereference

Mark Janes mark.a.janes at intel.com
Fri May 20 16:49:59 UTC 2016


Ilia Mirkin <imirkin at alum.mit.edu> writes:

> How can that happen? We just did an add, which failed -- IIRC that's
> only when there's a type already there. Then we went to get it and it
> wasn't there all of a sudden?

In the piglit test which provokes the crash, a symbol pre-exists in the
table, but it is not a type.  add_type() fails, then get_type() fails.

> On Fri, May 20, 2016 at 11:58 AM, Mark Janes <mark.a.janes at intel.com> wrote:
>> This trivially corrects mesa 3ca1c221, which introduced a check that
>> crashes when a match is not found.
>>
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95005
>> Fixes: piglit.spec.glsl-1_50.compiler.interface-blocks-name-reused-globally-4.vert
>> ---
>>  src/compiler/glsl/ast_to_hir.cpp | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
>> index ecfe684..a524fbd 100644
>> --- a/src/compiler/glsl/ast_to_hir.cpp
>> +++ b/src/compiler/glsl/ast_to_hir.cpp
>> @@ -6920,7 +6920,7 @@ ast_struct_specifier::hir(exec_list *instructions,
>>     if (!state->symbols->add_type(name, t)) {
>>        const glsl_type *match = state->symbols->get_type(name);
>>        /* allow struct matching for desktop GL - older UE4 does this */
>> -      if (state->is_version(130, 0) && match->record_compare(t, false))
>> +      if (match != NULL && state->is_version(130, 0) && match->record_compare(t, false))
>>           _mesa_glsl_warning(& loc, state, "struct `%s' previously defined", name);
>>        else
>>           _mesa_glsl_error(& loc, state, "struct `%s' previously defined", name);
>> --
>> 2.8.1
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list