intel/compiler: Fix dynarray usage in intel_clc

The code builds up the dynamic array of objects (spirv_objs) and
collect pointers to each of them into another dynamic
array (spirv_ptr_objs).

If the growth of the first array cause a reallocation, it is
possible that the previous pointers end up invalid.

Fixes: 77e929a527 ("intel/clc: allow multiple CL files to be compiled together")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19730>
(cherry picked from commit 9fd1d47aa0f19fac30d29e6ae40ed0383c1930ee)
This commit is contained in:
Caio Oliveira 2022-11-13 22:30:25 -08:00 committed by Dylan Baker
parent e514b07e34
commit c9e65acaad
2 changed files with 4 additions and 2 deletions

View File

@ -4,7 +4,7 @@
"description": "intel/compiler: Fix dynarray usage in intel_clc", "description": "intel/compiler: Fix dynarray usage in intel_clc",
"nominated": true, "nominated": true,
"nomination_type": 1, "nomination_type": 1,
"resolution": 0, "resolution": 1,
"main_sha": null, "main_sha": null,
"because_sha": "77e929a52734456237f5e0171a4844d6f9be027e" "because_sha": "77e929a52734456237f5e0171a4844d6f9be027e"
}, },

View File

@ -448,8 +448,10 @@ int main(int argc, char **argv)
ralloc_free(mem_ctx); ralloc_free(mem_ctx);
return 1; return 1;
} }
}
util_dynarray_append(&spirv_ptr_objs, struct clc_binary *, spirv_out); util_dynarray_foreach(&spirv_objs, struct clc_binary, p) {
util_dynarray_append(&spirv_ptr_objs, struct clc_binary *, p);
} }
/* The SPIRV-Tools linker started checking that all modules have the same /* The SPIRV-Tools linker started checking that all modules have the same