mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-11 04:50:35 +01:00
asahi: Fix shader key cloning overreads
We call agx_get_shader_variant through with casted inner shader key types, so it has to make sure to only copy as much of the union as is actually valid. Signed-off-by: Asahi Lina <lina@asahilina.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21348>
This commit is contained in:
parent
bac6062d10
commit
9daaa9e44e
1 changed files with 11 additions and 2 deletions
|
|
@ -1452,8 +1452,17 @@ agx_get_shader_variant(struct agx_screen *screen,
|
|||
* hash table key. The clone is logically owned by the hash table.
|
||||
*/
|
||||
union asahi_shader_key *cloned_key =
|
||||
ralloc(so->variants, union asahi_shader_key);
|
||||
memcpy(cloned_key, key, sizeof(union asahi_shader_key));
|
||||
rzalloc(so->variants, union asahi_shader_key);
|
||||
|
||||
if (so->type == PIPE_SHADER_FRAGMENT) {
|
||||
memcpy(cloned_key, key, sizeof(struct asahi_fs_shader_key));
|
||||
} else if (so->type == PIPE_SHADER_VERTEX) {
|
||||
memcpy(cloned_key, key, sizeof(struct asahi_vs_shader_key));
|
||||
} else {
|
||||
assert(gl_shader_stage_is_compute(so->type));
|
||||
/* No key */
|
||||
}
|
||||
|
||||
_mesa_hash_table_insert(so->variants, cloned_key, compiled);
|
||||
|
||||
return compiled;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue