Mesa (master): main: fix coverity error in _mesa_program_resource_find_name()
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jan 10 07:40:54 UTC 2020
Module: Mesa
Branch: master
Commit: 39c1892dd82e6a52cb6d7ea100dfee877bd4aa2c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=39c1892dd82e6a52cb6d7ea100dfee877bd4aa2c
Author: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
Date: Wed Jan 8 19:12:53 2020 +0100
main: fix coverity error in _mesa_program_resource_find_name()
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 at igalia.com>
Reviewed-by: Tapani Pälli <tapani.palli at intel.com>
---
src/mesa/main/shader_query.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 1a50abc31d0..9a16a28d393 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -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)
More information about the mesa-commit
mailing list