summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-08-25 07:32:10 +0200
committerGitHub <noreply@github.com>2022-08-25 07:32:10 +0200
commit04ec0de37a678d5cbd6a7d890391889a3848942f (patch)
tree98613af1d3b7e3e33a6fc7d801a91b40c363d52e
parent0569738a6e7d53af9e7de19b092c2b29d9ac4267 (diff)
parentaed350072f44058a4fc0c2b1c56080e9aef2c3e4 (diff)
Merge pull request #64855 from RandomShaper/spv_ref_zero_alloc
Avoid spurious alloc error in SPIRV-Reflect
-rw-r--r--thirdparty/spirv-reflect/patches/zero-calloc.patch28
-rw-r--r--thirdparty/spirv-reflect/spirv_reflect.c16
2 files changed, 39 insertions, 5 deletions
diff --git a/thirdparty/spirv-reflect/patches/zero-calloc.patch b/thirdparty/spirv-reflect/patches/zero-calloc.patch
new file mode 100644
index 0000000000..796fe1266a
--- /dev/null
+++ b/thirdparty/spirv-reflect/patches/zero-calloc.patch
@@ -0,0 +1,28 @@
+diff --git a/thirdparty/spirv-reflect/spirv_reflect.c b/thirdparty/spirv-reflect/spirv_reflect.c
+index c174ae1900..11ccbdee3a 100644
+--- a/thirdparty/spirv-reflect/spirv_reflect.c
++++ b/thirdparty/spirv-reflect/spirv_reflect.c
+@@ -3322,12 +3322,18 @@ static SpvReflectResult ParseExecutionModes(
+ }
+ for (size_t entry_point_idx = 0; entry_point_idx < p_module->entry_point_count; ++entry_point_idx) {
+ SpvReflectEntryPoint* p_entry_point = &p_module->entry_points[entry_point_idx];
+- p_entry_point->execution_modes =
+- (SpvExecutionMode*)calloc(p_entry_point->execution_mode_count, sizeof(*p_entry_point->execution_modes));
+- if (IsNull(p_entry_point->execution_modes)) {
+- SafeFree(indices);
+- return SPV_REFLECT_RESULT_ERROR_ALLOC_FAILED;
++// -- GODOT begin --
++ if (p_entry_point->execution_mode_count > 0) {
++// -- GODOT end --
++ p_entry_point->execution_modes =
++ (SpvExecutionMode*)calloc(p_entry_point->execution_mode_count, sizeof(*p_entry_point->execution_modes));
++ if (IsNull(p_entry_point->execution_modes)) {
++ SafeFree(indices);
++ return SPV_REFLECT_RESULT_ERROR_ALLOC_FAILED;
++ }
++// -- GODOT begin --
+ }
++// -- GODOT end --
+ }
+
+ for (size_t node_idx = 0; node_idx < p_parser->node_count; ++node_idx) {
diff --git a/thirdparty/spirv-reflect/spirv_reflect.c b/thirdparty/spirv-reflect/spirv_reflect.c
index c174ae1900..11ccbdee3a 100644
--- a/thirdparty/spirv-reflect/spirv_reflect.c
+++ b/thirdparty/spirv-reflect/spirv_reflect.c
@@ -3322,12 +3322,18 @@ static SpvReflectResult ParseExecutionModes(
}
for (size_t entry_point_idx = 0; entry_point_idx < p_module->entry_point_count; ++entry_point_idx) {
SpvReflectEntryPoint* p_entry_point = &p_module->entry_points[entry_point_idx];
- p_entry_point->execution_modes =
- (SpvExecutionMode*)calloc(p_entry_point->execution_mode_count, sizeof(*p_entry_point->execution_modes));
- if (IsNull(p_entry_point->execution_modes)) {
- SafeFree(indices);
- return SPV_REFLECT_RESULT_ERROR_ALLOC_FAILED;
+// -- GODOT begin --
+ if (p_entry_point->execution_mode_count > 0) {
+// -- GODOT end --
+ p_entry_point->execution_modes =
+ (SpvExecutionMode*)calloc(p_entry_point->execution_mode_count, sizeof(*p_entry_point->execution_modes));
+ if (IsNull(p_entry_point->execution_modes)) {
+ SafeFree(indices);
+ return SPV_REFLECT_RESULT_ERROR_ALLOC_FAILED;
+ }
+// -- GODOT begin --
}
+// -- GODOT end --
}
for (size_t node_idx = 0; node_idx < p_parser->node_count; ++node_idx) {