]> granicus.if.org Git - vim/commitdiff
patch 8.0.0155: ubsan complains about NULL pointer v8.0.0155
authorBram Moolenaar <Bram@vim.org>
Sun, 8 Jan 2017 16:46:20 +0000 (17:46 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 8 Jan 2017 16:46:20 +0000 (17:46 +0100)
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)

src/syntax.c
src/version.c

index b2108e4d93fa0b8f3233714710d70a6e1cc46f7a..80546bb02d612b0eb65229c08fe0995c9a353423 100644 (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"));
index 368e6bea32a3054fe46c19ac00d5116725317abb..d88c03be7d38286c82d9d9b31e6803bb42811614 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    155,
 /**/
     154,
 /**/