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 1a50abc31d037fee368248d4f64339e3a3e83d89..9a16a28d39337e6b4d52b36f905b319c368d0d3a 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)