summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHai Nguyen <379079+chaoticbob@users.noreply.github.com>2022-12-02 11:25:20 -0500
committerGitHub <noreply@github.com>2022-12-02 11:25:20 -0500
commit03b2a9d399ce2bdb6262313f9dcc453d7befd375 (patch)
tree3e089754c49c9a2bf828cc0e962d5b42eebd2f20
parent5b96d155b11963c64a97c0404839fb2bc9fc4aba (diff)
parentda7e87ed7a0a5ee2ff2bd81012f30f31028654ed (diff)
downloadSPIRV-Reflect-03b2a9d399ce2bdb6262313f9dcc453d7befd375.tar.gz
Merge pull request #157 from RandomShaper/fix_zero_entry_points
Fix spurious alloc error when there are no execution modes
-rw-r--r--spirv_reflect.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/spirv_reflect.c b/spirv_reflect.c
index 63f72de..5fc190e 100644
--- a/spirv_reflect.c
+++ b/spirv_reflect.c
@@ -3339,11 +3339,13 @@ 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;
+ if (p_entry_point->execution_mode_count > 0) {
+ 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;
+ }
}
}