summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2022-08-24 22:38:00 +0200
committerPedro J. Estébanez <pedrojrulez@gmail.com>2022-08-24 22:54:57 +0200
commitda7e87ed7a0a5ee2ff2bd81012f30f31028654ed (patch)
tree1791d490e94358e4a2837a8c4b4dd2969ca23598
parentb68b5a8a5d8ab5fce79e6596f3a731291046393a (diff)
downloadSPIRV-Reflect-da7e87ed7a0a5ee2ff2bd81012f30f31028654ed.tar.gz
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 8c70ebe..857837e 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;
+ }
}
}