diff --git a/.pick_status.json b/.pick_status.json index a7a0aea4b67..b11c8204682 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2174,7 +2174,7 @@ "description": "nir: fix use-after-free on function parameter names", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "3da8444be563a150fff6dd686dd68febf4cf76c9", "notes": null diff --git a/src/compiler/nir/nir_serialize.c b/src/compiler/nir/nir_serialize.c index 418dc06f252..d013bd78e48 100644 --- a/src/compiler/nir/nir_serialize.c +++ b/src/compiler/nir/nir_serialize.c @@ -2053,8 +2053,10 @@ read_function(read_ctx *ctx) for (unsigned i = 0; i < fxn->num_params; i++) { uint32_t val = blob_read_uint32(ctx->blob); bool has_name = (val & 0x10000); - if (has_name) - fxn->params[i].name = blob_read_string(ctx->blob); + if (has_name) { + char *name = blob_read_string(ctx->blob); + fxn->params[i].name = ralloc_strdup(ctx->nir, name); + } fxn->params[i].num_components = val & 0xff; fxn->params[i].bit_size = (val >> 8) & 0xff; diff --git a/src/compiler/nir/nir_sweep.c b/src/compiler/nir/nir_sweep.c index 009343c3cf9..70ebb2becb8 100644 --- a/src/compiler/nir/nir_sweep.c +++ b/src/compiler/nir/nir_sweep.c @@ -133,6 +133,9 @@ sweep_function(nir_shader *nir, nir_function *f) ralloc_steal(nir, f); ralloc_steal(nir, f->params); + for (unsigned i = 0; i < f->num_params; i++) + ralloc_steal(nir, (char *)f->params[i].name); + if (f->impl) sweep_impl(nir, f->impl); } diff --git a/src/compiler/spirv/vtn_opencl.c b/src/compiler/spirv/vtn_opencl.c index b8c74344a98..a824f4b3a14 100644 --- a/src/compiler/spirv/vtn_opencl.c +++ b/src/compiler/spirv/vtn_opencl.c @@ -154,6 +154,7 @@ static nir_function *mangle_and_find(struct vtn_builder *b, decl->params = ralloc_array(b->shader, nir_parameter, decl->num_params); for (unsigned i = 0; i < decl->num_params; i++) { decl->params[i] = found->params[i]; + decl->params[i].name = ralloc_strdup(b->shader, found->params[i].name); } found = decl; }