summaryrefslogtreecommitdiff
path: root/ext/bigdecimal
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-22 05:54:05 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-22 05:54:05 +0000
commit467c9ec3b767a4c024ef50587a5a7ac1a150d2c2 (patch)
tree4d3adc1aa420088e880086298e8b6dd49519b5bb /ext/bigdecimal
parent4131c29f8794d3ad774409692d3a4eb9a6d2e49d (diff)
* ext/bigdecimal/bigdecimal.c (BigMath_s_exp): Fix the inserting points
of RB_GC_GUARDs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r--ext/bigdecimal/bigdecimal.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 096cc4b..9954322 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -2711,22 +2711,22 @@ BigMath_s_exp(VALUE klass, VALUE x, VALUE vprec)
else {
Real* vy;
vy = VpCreateRbObject(prec, "#0");
- RB_GC_GUARD(vy->obj);
VpSetInf(vy, VP_SIGN_POSITIVE_INFINITE);
+ RB_GC_GUARD(vy->obj);
return ToValue(vy);
}
}
else if (nan) {
Real* vy;
vy = VpCreateRbObject(prec, "#0");
- RB_GC_GUARD(vy->obj);
VpSetNaN(vy);
+ RB_GC_GUARD(vy->obj);
return ToValue(vy);
}
else if (vx == NULL) {
cannot_be_coerced_into_BigDecimal(rb_eArgError, x);
}
- x = RB_GC_GUARD(vx->obj);
+ x = vx->obj;
n = prec + rmpd_double_figures();
negative = VpGetSign(vx) < 0;
@@ -2734,12 +2734,12 @@ BigMath_s_exp(VALUE klass, VALUE x, VALUE vprec)
VpSetSign(vx, 1);
}
- RB_GC_GUARD(one) = ToValue(VpCreateRbObject(1, "1"));
- RB_GC_GUARD(x1) = one;
- RB_GC_GUARD(y) = one;
- RB_GC_GUARD(d) = y;
- RB_GC_GUARD(z) = one;
- i = 0;
+ one = ToValue(VpCreateRbObject(1, "1"));
+ x1 = one;
+ y = one;
+ d = y;
+ z = one;
+ i = 0;
while (!VpIsZero((Real*)DATA_PTR(d))) {
VALUE argv[2];
@@ -2772,6 +2772,13 @@ BigMath_s_exp(VALUE klass, VALUE x, VALUE vprec)
vprec = SSIZET2NUM(prec - VpExponent10(DATA_PTR(y)));
return BigDecimal_round(1, &vprec, y);
}
+
+ RB_GC_GUARD(one);
+ RB_GC_GUARD(x);
+ RB_GC_GUARD(x1);
+ RB_GC_GUARD(y);
+ RB_GC_GUARD(d);
+ RB_GC_GUARD(z);
}
/* call-seq: