changeset 10530:ea5adbeccfc1 v8.0.0155

commit https://github.com/vim/vim/commit/a216255a4faa91a15e7005ac319f2f62294f3f9e Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 8 17:46:20 2017 +0100 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)
author Christian Brabandt <cb@256bit.org>
date Sun, 08 Jan 2017 18:00:04 +0100
parents 9a58ba599996
children 3ddb8fa7be7d
files src/syntax.c src/version.c
diffstat 2 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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"));
--- 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,