Mesa (master): intel/compiler: Do not qsort zero sized array
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Feb 19 10:43:29 UTC 2020
Module: Mesa
Branch: master
Commit: d5931f285be246be95683c2fb054694d89d07657
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d5931f285be246be95683c2fb054694d89d07657
Author: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
Date: Tue Jan 28 16:30:55 2020 +0200
intel/compiler: Do not qsort zero sized array
../src/intel/compiler/brw_nir_analyze_ubo_ranges.c:316:4: runtime error: null pointer passed as argument 1, which is declared to never be null
#0 0x7f78f5916611 in brw_nir_analyze_ubo_ranges ../src/intel/compiler/brw_nir_analyze_ubo_ranges.c:316
#1 0x7f78f255c189 in brw_codegen_wm_prog ../src/mesa/drivers/dri/i965/brw_wm.c:97
#2 0x7f78f2565571 in brw_fs_precompile ../src/mesa/drivers/dri/i965/brw_wm.c:608
#3 0x7f78f24edd2c in brw_shader_precompile ../src/mesa/drivers/dri/i965/brw_link.cpp:56
#4 0x7f78f24f3af8 in brw_link_shader ../src/mesa/drivers/dri/i965/brw_link.cpp:381
#5 0x7f78f39a302a in _mesa_glsl_link_shader ../src/mesa/program/ir_to_mesa.cpp:3119
#6 0x7f78f3a43826 in create_new_program ../src/mesa/main/ff_fragment_shader.cpp:1133
#7 0x7f78f3a43d00 in _mesa_get_fixed_func_fragment_program ../src/mesa/main/ff_fragment_shader.cpp:1163
#8 0x7f78f325ddcd in update_program ../src/mesa/main/state.c:134
#9 0x7f78f325fe64 in _mesa_update_state_locked ../src/mesa/main/state.c:360
#10 0x7f78f32600f1 in _mesa_update_state ../src/mesa/main/state.c:394
#11 0x7f78f2b3e587 in clear ../src/mesa/main/clear.c:169
#12 0x7f78f2b3e587 in _mesa_Clear ../src/mesa/main/clear.c:242
Signed-off-by: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3825>
---
src/intel/compiler/brw_nir_analyze_ubo_ranges.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
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;
More information about the mesa-commit
mailing list