From 7b768e43354391098929adf97a593fae79d5fc2e Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Tue, 21 Feb 2023 14:16:45 +0100 Subject: [ruby/bigdecimal] Move RB_GC_GUARD() at the end, like in BigMath_s_exp() https://github.com/ruby/bigdecimal/commit/b66ef9fbb5 --- ext/bigdecimal/bigdecimal.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'ext/bigdecimal') diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index b4e32c709e..ae37c65f4c 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -4144,12 +4144,9 @@ get_vp_value: one = VpCheckGetValue(NewOneWrapLimited(1, 1)); two = VpCheckGetValue(VpCreateRbObject(1, "2", true)); - RB_GC_GUARD(one); - RB_GC_GUARD(two); n = prec + BIGDECIMAL_DOUBLE_FIGURES; vn = SSIZET2NUM(n); - RB_GC_GUARD(vn); expo = VpExponent10(vx); if (expo < 0 || expo >= 3) { char buf[DECIMAL_SIZE_OF_BITS(SIZEOF_VALUE * CHAR_BIT) + 4]; @@ -4164,9 +4161,6 @@ get_vp_value: x2 = BigDecimal_mult2(x, x, vn); y = x; d = y; - RB_GC_GUARD(x2); - RB_GC_GUARD(y); - RB_GC_GUARD(d); i = 1; while (!VpIsZero((Real*)DATA_PTR(d))) { SIGNED_VALUE const ey = VpExponent10(DATA_PTR(y)); @@ -4194,6 +4188,13 @@ get_vp_value: y = BigDecimal_add(y, dy); } + RB_GC_GUARD(one); + RB_GC_GUARD(two); + RB_GC_GUARD(vn); + RB_GC_GUARD(x2); + RB_GC_GUARD(y); + RB_GC_GUARD(d); + return y; } -- cgit v1.2.3