From bbac52873f4248c2f545f12137bd24071a8043cc Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Tue, 24 Sep 2019 17:21:51 +0100 Subject: [PATCH] aco: fix uninitialized data in the binary MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Rhys Perry Reviewed-By: Timur Kristóf Fixes: 93c8ebfa780 ('aco: Initial commit of independent AMD compiler') Part-of: --- src/amd/compiler/aco_interface.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/amd/compiler/aco_interface.cpp b/src/amd/compiler/aco_interface.cpp index 802adcefb1b..f951c4fdc5f 100644 --- a/src/amd/compiler/aco_interface.cpp +++ b/src/amd/compiler/aco_interface.cpp @@ -154,7 +154,11 @@ void aco_compile_shader(unsigned shader_count, } size += code.size() * sizeof(uint32_t) + sizeof(radv_shader_binary_legacy); - radv_shader_binary_legacy* legacy_binary = (radv_shader_binary_legacy*) malloc(size); + /* We need to calloc to prevent unintialized data because this will be used + * directly for the disk cache. Uninitialized data can appear because of + * padding in the struct or because legacy_binary->data can be at an offset + * from the start less than sizeof(radv_shader_binary_legacy). */ + radv_shader_binary_legacy* legacy_binary = (radv_shader_binary_legacy*) calloc(size, 1); legacy_binary->base.type = RADV_BINARY_TYPE_LEGACY; legacy_binary->base.stage = shaders[shader_count-1]->info.stage; -- 2.30.2