From c9e65acaade6af2aa39fa5be76e092b39dc631c7 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Sun, 13 Nov 2022 22:30:25 -0800 Subject: [PATCH] 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: 77e929a5273 ("intel/clc: allow multiple CL files to be compiled together") Reviewed-by: Lionel Landwerlin Reviewed-by: Jordan Justen Part-of: (cherry picked from commit 9fd1d47aa0f19fac30d29e6ae40ed0383c1930ee) --- .pick_status.json | 2 +- src/intel/compiler/intel_clc.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 2fa61691db1..232699a6179 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -4,7 +4,7 @@ "description": "intel/compiler: Fix dynarray usage in intel_clc", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "77e929a52734456237f5e0171a4844d6f9be027e" }, diff --git a/src/intel/compiler/intel_clc.c b/src/intel/compiler/intel_clc.c index 0d554882a9b..53e520a84e7 100644 --- a/src/intel/compiler/intel_clc.c +++ b/src/intel/compiler/intel_clc.c @@ -448,8 +448,10 @@ int main(int argc, char **argv) ralloc_free(mem_ctx); 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