From 4ce32b754a017c48e8997baa102f505bfdd01135 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Mon, 6 May 2024 14:05:14 +0200 Subject: [PATCH] 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: 2aa9eb497d0 ("nir: Add a helper for finding a function by name") Signed-off-by: Karol Herbst Part-of: (cherry picked from commit 569c2fcf952a3ec13ddf77c0058e769bf68f3aaf) --- .pick_status.json | 2 +- src/compiler/nir/nir.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 551119b1d56..737d8ae502e 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -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 diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 58b602e8a8b..62286b56b03 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -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; }