main: fix coverity error in _mesa_program_resource_find_name()
authorSamuel Iglesias Gonsálvez <siglesias@igalia.com>
Wed, 8 Jan 2020 18:12:53 +0000 (19:12 +0100)
committerSamuel Iglesias Gonsálvez <siglesias@igalia.com>
Fri, 10 Jan 2020 07:40:00 +0000 (08:40 +0100)
We did not take into account if name is NULL, so we could dereference
a NULL pointer in strncmp() call.

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
src/mesa/main/shader_query.cpp

index 1a50abc..9a16a28 100644 (file)
@@ -581,8 +581,11 @@ _mesa_program_resource_find_name(struct gl_shader_program *shProg,
 {
    struct gl_program_resource *res = NULL;
 
+   if (name == NULL)
+      return NULL;
+
    /* If we have a name, try the ProgramResourceHash first. */
-   if (name && shProg->data->ProgramResourceHash)
+   if (shProg->data->ProgramResourceHash)
       res = search_resource_hash(shProg, programInterface, name, array_index);
 
    if (res)