diff options
author | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2022-08-24 22:38:00 +0200 |
---|---|---|
committer | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2022-08-24 22:54:57 +0200 |
commit | da7e87ed7a0a5ee2ff2bd81012f30f31028654ed (patch) | |
tree | 1791d490e94358e4a2837a8c4b4dd2969ca23598 | |
parent | b68b5a8a5d8ab5fce79e6596f3a731291046393a (diff) | |
download | SPIRV-Reflect-da7e87ed7a0a5ee2ff2bd81012f30f31028654ed.tar.gz |
Fix spurious alloc error when there are no execution modes
-rw-r--r-- | spirv_reflect.c | 12 |
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; + } } } |