0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.0.0155: ubsan complains about NULL pointer

Problem:    When sorting zero elements a NULL pointer is passed to qsort(),
            which ubsan warns for.
Solution:   Don't call qsort() if there are no elements. (Dominique Pelle)
This commit is contained in:
Bram Moolenaar
2017-01-08 17:46:20 +01:00
parent 31f19ce0a0
commit a216255a4f
2 changed files with 6 additions and 2 deletions

View File

@@ -6704,8 +6704,10 @@ syntime_report(void)
}
}
/* sort on total time */
qsort(ga.ga_data, (size_t)ga.ga_len, sizeof(time_entry_T),
/* Sort on total time. Skip if there are no items to avoid passing NULL
* pointer to qsort(). */
if (ga.ga_len > 1)
qsort(ga.ga_data, (size_t)ga.ga_len, sizeof(time_entry_T),
syn_compare_syntime);
MSG_PUTS_TITLE(_(" TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN"));