summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/bigdecimal/bigdecimal.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index b161bc95ca..7cd0044532 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -2046,6 +2046,7 @@ static VALUE
rmpd_power_by_big_decimal(Real const* x, Real const* exp, ssize_t const n)
{
VALUE log_x, multiplied, y;
+ volatile VALUE obj = exp->obj;
if (VpIsZero(exp)) {
return ToValue(VpCreateRbObject(n, "1"));
@@ -2054,6 +2055,7 @@ rmpd_power_by_big_decimal(Real const* x, Real const* exp, ssize_t const n)
log_x = BigMath_log(x->obj, SSIZET2NUM(n+1));
multiplied = BigDecimal_mult2(exp->obj, log_x, SSIZET2NUM(n+1));
y = BigMath_exp(multiplied, SSIZET2NUM(n));
+ RB_GC_GUARD(obj);
return y;
}