Skip to content

Commit a216255

Browse files
committed
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)
1 parent 31f19ce commit a216255

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/syntax.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6704,8 +6704,10 @@ syntime_report(void)
67046704
}
67056705
}
67066706

6707-
/* sort on total time */
6708-
qsort(ga.ga_data, (size_t)ga.ga_len, sizeof(time_entry_T),
6707+
/* Sort on total time. Skip if there are no items to avoid passing NULL
6708+
* pointer to qsort(). */
6709+
if (ga.ga_len > 1)
6710+
qsort(ga.ga_data, (size_t)ga.ga_len, sizeof(time_entry_T),
67096711
syn_compare_syntime);
67106712

67116713
MSG_PUTS_TITLE(_(" TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN"));

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
155,
767769
/**/
768770
154,
769771
/**/

0 commit comments

Comments
 (0)