From: Bram Moolenaar Date: Sun, 8 Jan 2017 16:46:20 +0000 (+0100) Subject: patch 8.0.0155: ubsan complains about NULL pointer X-Git-Tag: v8.0.0155 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a216255a4faa91a15e7005ac319f2f62294f3f9e;p=vim 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) --- diff --git a/src/syntax.c b/src/syntax.c index b2108e4d9..80546bb02 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -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")); diff --git a/src/version.c b/src/version.c index 368e6bea3..d88c03be7 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 155, /**/ 154, /**/