nir: fix nir_shader_get_function_for_name for functions without names.

It's legal in SPIRV for functions to not have names, we have to take this
into account when calling into strcmp here.

Fixes: 2aa9eb497d ("nir: Add a helper for finding a function by name")
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29063>
(cherry picked from commit 569c2fcf95)
This commit is contained in:
Karol Herbst 2024-05-06 14:05:14 +02:00 committed by Eric Engestrom
parent d4eaa3f7f2
commit 4ce32b754a
2 changed files with 2 additions and 2 deletions

View file

@ -434,7 +434,7 @@
"description": "nir: fix nir_shader_get_function_for_name for functions without names.",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "2aa9eb497d0f670136b5c2a50b962f4ce0faa917",
"notes": null

View file

@ -4185,7 +4185,7 @@ static inline nir_function *
nir_shader_get_function_for_name(const nir_shader *shader, const char *name)
{
nir_foreach_function(func, shader) {
if (strcmp(func->name, name) == 0)
if (func->name && strcmp(func->name, name) == 0)
return func;
}