nir/lower_shader_calls: skip zero-sized qsort

Fixes UBSan:
src/compiler/nir/nir_lower_shader_calls.c:1681:7: runtime error: null pointer passed as argument 1, which is declared to never be null

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25853>
This commit is contained in:
Rhys Perry
2023-09-27 14:23:09 +01:00
committed by Marge Bot
parent f9289dfd02
commit 1afd0878e9

View File

@@ -1678,10 +1678,12 @@ nir_opt_sort_and_pack_stack(nir_shader *shader,
}
/* Sort scratch item by component size. */
qsort(util_dynarray_begin(&ops),
util_dynarray_num_elements(&ops, struct scratch_item),
sizeof(struct scratch_item),
sort_scratch_item_by_size_and_value_id);
if (util_dynarray_num_elements(&ops, struct scratch_item)) {
qsort(util_dynarray_begin(&ops),
util_dynarray_num_elements(&ops, struct scratch_item),
sizeof(struct scratch_item),
sort_scratch_item_by_size_and_value_id);
}
/* Reorder things on the stack */
_mesa_hash_table_u64_clear(value_id_to_item);