diff --git a/src/intel/compiler/brw_nir_analyze_ubo_ranges.c b/src/intel/compiler/brw_nir_analyze_ubo_ranges.c index 35b0c945343..bdf766159aa 100644 --- a/src/intel/compiler/brw_nir_analyze_ubo_ranges.c +++ b/src/intel/compiler/brw_nir_analyze_ubo_ranges.c @@ -313,8 +313,10 @@ brw_nir_analyze_ubo_ranges(const struct brw_compiler *compiler, */ /* Sort the list so the most beneficial ranges are at the front. */ - qsort(ranges.data, nr_entries, sizeof(struct ubo_range_entry), - cmp_ubo_range_entry); + if (nr_entries > 0) { + qsort(ranges.data, nr_entries, sizeof(struct ubo_range_entry), + cmp_ubo_range_entry); + } struct ubo_range_entry *entries = ranges.data;