aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2005-10-10 01:03:59 +0000
committerJoel Brobecker <brobecker@gnat.com>2005-10-10 01:03:59 +0000
commit168de233a78e1a72a4415c3618dba3ff2428f850 (patch)
treee8ce08c633d0fc1d79be011fa6d8cf42e124c235 /gdb
parentad5da28ce619a3843bc5b290645f1bbf334e0674 (diff)
downloadfsf-binutils-gdb-168de233a78e1a72a4415c3618dba3ff2428f850.zip
fsf-binutils-gdb-168de233a78e1a72a4415c3618dba3ff2428f850.tar.gz
fsf-binutils-gdb-168de233a78e1a72a4415c3618dba3ff2428f850.tar.bz2
* valprint.c (val_print_array_elements): Check array size before
computing its low bound. If zero, then use a default bound of zero.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/valprint.c16
2 files changed, 14 insertions, 7 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2cfa2b5..c0f89fd 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2005-10-05 Joel Brobecker <brobecker@adacore.com>
+
+ * valprint.c (val_print_array_elements): Check array size before
+ computing its low bound. If zero, then use a default bound of zero.
+
2005-10-06 Alan Modra <amodra@bigpond.net.au>
PR 1659
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 60149ac..3183a8d 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -959,19 +959,21 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
unsigned int rep1;
/* Number of repetitions we have detected so far. */
unsigned int reps;
- long low_bound_index;
-
- if (!get_array_low_bound (type, &low_bound_index))
- {
- warning ("unable to get low bound of array, using zero as default");
- low_bound_index = 0;
- }
+ long low_bound_index = 0;
elttype = TYPE_TARGET_TYPE (type);
eltlen = TYPE_LENGTH (check_typedef (elttype));
len = TYPE_LENGTH (type) / eltlen;
index_type = TYPE_INDEX_TYPE (type);
+ /* Get the array low bound. This only makes sense if the array
+ has one or more element in it. */
+ if (len > 0 && !get_array_low_bound (type, &low_bound_index))
+ {
+ warning ("unable to get low bound of array, using zero as default");
+ low_bound_index = 0;
+ }
+
annotate_array_section_begin (i, elttype);
for (; i < len && things_printed < print_max; i++)