summaryrefslogtreecommitdiff
path: root/gdb/valarith.c
diff options
context:
space:
mode:
authorDavid Lecomber <david@lecomber.net>2004-06-27 07:57:15 +0000
committerDavid Lecomber <david@lecomber.net>2004-06-27 07:57:15 +0000
commitba3eea91dda0db2ad9ca9b5d868115808163ae47 (patch)
tree83283a9dd375ab1550c058489f637baaccc48fea /gdb/valarith.c
parente5910e25fd5509953afc9f6ea512fee513936979 (diff)
downloadgdb-ba3eea91dda0db2ad9ca9b5d868115808163ae47.tar.gz
2004-06-27 <david@streamline-computing.com>
Partial fix for PR cli/1056. * valarith.c (value_binop): Check for zero in division and remainder evaluation.
Diffstat (limited to 'gdb/valarith.c')
-rw-r--r--gdb/valarith.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 1a86e921f42..7858f91d0de 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -1040,7 +1040,10 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
break;
case BINOP_DIV:
- v = v1 / v2;
+ if (v2 != 0)
+ v = v1 / v2;
+ else
+ error ("Division by zero");
break;
case BINOP_EXP:
@@ -1050,7 +1053,10 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
break;
case BINOP_REM:
- v = v1 % v2;
+ if (v2 != 0)
+ v = v1 % v2;
+ else
+ error ("Division by zero");
break;
case BINOP_MOD: