summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-06-24 19:14:47 +0100
committerPádraig Brady <P@draigBrady.com>2015-06-24 19:15:31 +0100
commit77547ba7b26aa65fc0f6dfcc0cb8235686699611 (patch)
tree8f06d549184fb90506b94b2a13524c421e9cabab
parent4d2d6c5b7c455392617609ae21b6b21879e12975 (diff)
downloadcoreutils-77547ba7b26aa65fc0f6dfcc0cb8235686699611.tar.xz
maint: avoid undefined behavior in qsort call
GCC 5.1.1 -fsanitize=undefined with glibc 2.21 is returning: "runtime error: null pointer passed as argument 1, which is declared to never be null" * src/ptx.c (sort_found_occurs): Avoid the call with no entries.
-rw-r--r--src/ptx.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/ptx.c b/src/ptx.c
index ff4e63a5f..3aea4cdf2 100644
--- a/src/ptx.c
+++ b/src/ptx.c
@@ -631,9 +631,9 @@ sort_found_occurs (void)
{
/* Only one language for the time being. */
-
- qsort (occurs_table[0], number_of_occurs[0], sizeof **occurs_table,
- compare_occurs);
+ if (number_of_occurs[0])
+ qsort (occurs_table[0], number_of_occurs[0], sizeof **occurs_table,
+ compare_occurs);
}
/* Parameter files reading routines. */