diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-01-08 17:46:20 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-01-08 17:46:20 +0100 |
commit | a216255a4faa91a15e7005ac319f2f62294f3f9e (patch) | |
tree | b26ce4a074f220711b9da9d573cc37e3d60db6ef | |
parent | 31f19ce0a052f7c76d44a9a190e468c79cf5d56d (diff) |
patch 8.0.0155: ubsan complains about NULL pointerv8.0.0155
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)
-rw-r--r-- | src/syntax.c | 6 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/syntax.c b/src/syntax.c index b2108e4d93..80546bb02d 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 368e6bea32..d88c03be7d 100644 --- a/src/version.c +++ b/src/version.c @@ -765,6 +765,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 155, +/**/ 154, /**/ 153, |