[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] maint: avoid undefined behavior in qsort call
From: |
Pádraig Brady |
Subject: |
[PATCH] maint: avoid undefined behavior in qsort call |
Date: |
Wed, 24 Jun 2015 19:15:55 +0100 |
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.
---
src/ptx.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/ptx.c b/src/ptx.c
index ff4e63a..3aea4cd 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. */
--
2.4.1
- [PATCH] maint: avoid undefined behavior in qsort call,
Pádraig Brady <=