aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-03-19 19:16:00 +0000
committerths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-03-19 19:16:00 +0000
commit9bb234b3b170299c39c9e88cfe7da5434a92d99d (patch)
tree2415a3ecd043d9d76b00927e665b81182fbafcde
parent290a0933c0488a5072bed5458b1b9fe4dc84cba4 (diff)
Fix qemu crash due to sparc division-by-zero, by Aurelien Jarno.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2510 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--target-sparc/op.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/target-sparc/op.c b/target-sparc/op.c
index fd30e90e1f..9e16a29a43 100644
--- a/target-sparc/op.c
+++ b/target-sparc/op.c
@@ -671,6 +671,11 @@ void OPPROTO op_udiv_T1_T0(void)
x0 = T0 | ((uint64_t) (env->y) << 32);
x1 = T1;
+
+ if (x1 == 0) {
+ raise_exception(TT_DIV_ZERO);
+ }
+
x0 = x0 / x1;
if (x0 > 0xffffffff) {
T0 = 0xffffffff;
@@ -689,6 +694,11 @@ void OPPROTO op_sdiv_T1_T0(void)
x0 = T0 | ((int64_t) (env->y) << 32);
x1 = T1;
+
+ if (x1 == 0) {
+ raise_exception(TT_DIV_ZERO);
+ }
+
x0 = x0 / x1;
if ((int32_t) x0 != x0) {
T0 = x0 < 0? 0x80000000: 0x7fffffff;