aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/objc-lang.c5
2 files changed, 10 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6541837..6ad4b49 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2013-11-12 Andreas Arnez <arnez@linux.vnet.ibm.com>
+
+ * objc-lang.c (uniquify_strings): Prevent invoking qsort with
+ NULL.
+
2013-11-12 Doug Evans <dje@google.com>
Work around gold/15646.
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 77a61ac..5c72340 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -1056,6 +1056,11 @@ uniquify_strings (VEC (const_char_ptr) **strings)
const char *elem, *last = NULL;
int out;
+ /* If the vector is empty, there's nothing to do. This explicit
+ check is needed to avoid invoking qsort with NULL. */
+ if (VEC_empty (const_char_ptr, *strings))
+ return;
+
qsort (VEC_address (const_char_ptr, *strings),
VEC_length (const_char_ptr, *strings),
sizeof (const_char_ptr),