summaryrefslogtreecommitdiffstats
path: root/eqn_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2022-01-13 04:06:16 +0000
committerIngo Schwarze <schwarze@openbsd.org>2022-01-13 04:06:16 +0000
commit9000d2ef3dea08a1b8e264f86867952cf7388ab5 (patch)
treeb85ad75e804da82cb64cd7f11c89fa4f542fde7a /eqn_term.c
parent823d9076cdec1e28f8ffe58a9773905ba9dd4d96 (diff)
downloadmandoc-9000d2ef3dea08a1b8e264f86867952cf7388ab5.tar.gz
Only sort the result array if it contains more than one element,
making the mansearch() function easier to read for human auditors. No functional change on OpenBSD. As observed by Mark Millard <marklmi at yahoo dot com>, neither the latest version of POSIX 2008 nor C11 defines what qsort(3) should do for base == NULL && nmemb == 0. My impression is it is indeed undefined behaviour because the standards say that base shall point to an array, NULL does not point to an array, and while there is special wording saying that compar() shall not be called if nmemb == 0, i fail to see any similar wording stating that base shall not be accessed if nmemb == 0. Consequently, this patch is also likely to improve standard conformance and portability. Minor issue found by Stefan Esser <se at FreeBSD> with UBSAN. He sent a patch to bugs@, but my patch differs in a minor way.
Diffstat (limited to 'eqn_term.c')
0 files changed, 0 insertions, 0 deletions