diff options
author | Tom Tromey <tromey@adacore.com> | 2020-12-14 07:35:45 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2020-12-14 07:35:45 -0700 |
commit | a3bdae4ef826f2b59cc475e530b2a4130185cfac (patch) | |
tree | 18d4c1cd273e34ce9e7766d9a824d58ab14daec3 /gdb/valarith.c | |
parent | bf6d80378274fa33001f2ca1cef084eabc904178 (diff) | |
download | gdb-a3bdae4ef826f2b59cc475e530b2a4130185cfac.zip gdb-a3bdae4ef826f2b59cc475e530b2a4130185cfac.tar.gz gdb-a3bdae4ef826f2b59cc475e530b2a4130185cfac.tar.bz2 |
Handle fixed-point division by zero
fixed_point_binop did not account for division by zero. This would
lead to gdb getting SIGFPE and subsequently cause some test cases to
hang.
gdb/ChangeLog
2020-12-14 Tom Tromey <tromey@adacore.com>
* valarith.c (fixed_point_binop): Call error on division by zero.
gdb/testsuite/ChangeLog
2020-12-14 Tom Tromey <tromey@adacore.com>
* gdb.dwarf2/dw2-fixed-point.exp: Add test for division by zero.
Diffstat (limited to 'gdb/valarith.c')
-rw-r--r-- | gdb/valarith.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/gdb/valarith.c b/gdb/valarith.c index 37988f1..6854d9b 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -965,6 +965,8 @@ fixed_point_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) break; case BINOP_DIV: + if (mpq_sgn (v2.val) == 0) + error (_("Division by zero")); mpq_div (res.val, v1.val, v2.val); val = fixed_point_to_value (res); break; |