mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 13:38:06 +02:00
nir: fix use-after-free on function parameter names
Fixes:3da8444be5("nir: add names to function parameters") Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35098> (cherry picked from commitbc444f6d26)
This commit is contained in:
parent
f1672e0be2
commit
b456049782
4 changed files with 9 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue