diff --git a/src/microsoft/compiler/dxil_module.c b/src/microsoft/compiler/dxil_module.c index 6b3089442b4..8909df99d04 100644 --- a/src/microsoft/compiler/dxil_module.c +++ b/src/microsoft/compiler/dxil_module.c @@ -1852,7 +1852,8 @@ add_function(struct dxil_module *m, const char *name, if (!func) return NULL; - func->name = ralloc_strdup(func, name); + /* Truncate function name to make emit_symtab_entry() happy. */ + func->name = ralloc_strndup(func, name, 253); if (!func->name) { return NULL; } @@ -2218,7 +2219,7 @@ emit_symtab_entry(struct dxil_module *m, unsigned value, const char *name) temp[0] = VST_CODE_ENTRY; temp[1] = value; for (int i = 0; i < strlen(name); ++i) - temp[i + 2] = name[i]; + temp[i + 2] = (uint8_t)(name[i]); enum value_symtab_abbrev_id abbrev = VST_ABBREV_ENTRY_8; if (is_char6_string(name)) @@ -2492,7 +2493,7 @@ emit_metadata_string(struct dxil_module *m, const char *str) assert(strlen(str) < ARRAY_SIZE(data) - 1); data[0] = METADATA_STRING; for (size_t i = 0; i < strlen(str); ++i) - data[i + 1] = str[i]; + data[i + 1] = (uint8_t)(str[i]); return emit_metadata_abbrev_record(m, METADATA_ABBREV_STRING, data, strlen(str) + 1); diff --git a/src/microsoft/compiler/nir_to_dxil.c b/src/microsoft/compiler/nir_to_dxil.c index c8a17c4ef9e..5b4b6c91f41 100644 --- a/src/microsoft/compiler/nir_to_dxil.c +++ b/src/microsoft/compiler/nir_to_dxil.c @@ -1471,8 +1471,11 @@ emit_entrypoint(struct ntd_context *ctx, const struct dxil_mdnode *resources, const struct dxil_mdnode *shader_props) { + char truncated_name[254] = { 0 }; + strncpy(truncated_name, name, ARRAY_SIZE(truncated_name) - 1); + const struct dxil_mdnode *func_md = dxil_get_metadata_func(&ctx->mod, func); - const struct dxil_mdnode *name_md = dxil_get_metadata_string(&ctx->mod, name); + const struct dxil_mdnode *name_md = dxil_get_metadata_string(&ctx->mod, truncated_name); const struct dxil_mdnode *nodes[] = { func_md, name_md,