From 783b3602325d45e7b81c78c90f06b204c610467c Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Fri, 24 Feb 2023 13:25:25 +0100 Subject: [PATCH] Use the same fix as upstream for bigdecimal RB_GC_GUARD * See https://github.com/ruby/bigdecimal/pull/256 --- src/main/c/bigdecimal/bigdecimal.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/c/bigdecimal/bigdecimal.c b/src/main/c/bigdecimal/bigdecimal.c index 8216fcf0dc32..a3ec0100705b 100644 --- a/src/main/c/bigdecimal/bigdecimal.c +++ b/src/main/c/bigdecimal/bigdecimal.c @@ -3955,12 +3955,9 @@ BigMath_s_log(VALUE klass, VALUE x, VALUE vprec) one = VpCheckGetValue(VpCreateRbObject(1, "1", true)); 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]; @@ -3975,9 +3972,6 @@ BigMath_s_log(VALUE klass, VALUE x, VALUE vprec) 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)); @@ -4005,6 +3999,13 @@ BigMath_s_log(VALUE klass, VALUE x, VALUE vprec) 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; }