diff options
author | Tom Tromey <tom@tromey.com> | 2022-02-24 09:01:42 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2022-02-24 14:38:08 -0700 |
commit | 4c937052c13b13053559a5aa2b1345545a185ca5 (patch) | |
tree | da1c7680fef3345636fffc45b22592a59150f0f4 /gdb/f-valprint.c | |
parent | 7124770976d3f051532faf864013b76ab36249bf (diff) | |
download | gdb-4c937052c13b13053559a5aa2b1345545a185ca5.zip gdb-4c937052c13b13053559a5aa2b1345545a185ca5.tar.gz gdb-4c937052c13b13053559a5aa2b1345545a185ca5.tar.bz2 |
Fix crash in Fortran code
PR fortran/28801 points out a gdb crash that can be provoked by
certain Fortran code. The bug is that f77_get_upperbound assumes the
property is either a constant or undefined, but in this case it is
PROP_LOCEXPR.
This patch fixes the crash by making this function (and the
lower-bound one as well) do the correct check before calling
'const_val'.
Thanks to Andrew for writing the test case.
Co-authored-by: Andrew Burgess <aburgess@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28801
Diffstat (limited to 'gdb/f-valprint.c')
-rw-r--r-- | gdb/f-valprint.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 6a199f1..b64750b 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -43,7 +43,7 @@ static void f77_get_dynamic_length_of_aggregate (struct type *); LONGEST f77_get_lowerbound (struct type *type) { - if (type->bounds ()->low.kind () == PROP_UNDEFINED) + if (type->bounds ()->low.kind () != PROP_CONST) error (_("Lower bound may not be '*' in F77")); return type->bounds ()->low.const_val (); @@ -52,7 +52,7 @@ f77_get_lowerbound (struct type *type) LONGEST f77_get_upperbound (struct type *type) { - if (type->bounds ()->high.kind () == PROP_UNDEFINED) + if (type->bounds ()->high.kind () != PROP_CONST) { /* We have an assumed size array on our hands. Assume that upper_bound == lower_bound so that we show at least 1 element. |