Skip to content

Commit ead9146

Browse files
committed
[GR-17457] Use the same fix as upstream for bigdecimal RB_GC_GUARD
PullRequest: truffleruby/3665
2 parents 0e00805 + ac766c5 commit ead9146

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/main/c/bigdecimal/bigdecimal.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3955,12 +3955,9 @@ BigMath_s_log(VALUE klass, VALUE x, VALUE vprec)
39553955

39563956
one = VpCheckGetValue(VpCreateRbObject(1, "1", true));
39573957
two = VpCheckGetValue(VpCreateRbObject(1, "2", true));
3958-
RB_GC_GUARD(one);
3959-
RB_GC_GUARD(two);
39603958

39613959
n = prec + BIGDECIMAL_DOUBLE_FIGURES;
39623960
vn = SSIZET2NUM(n);
3963-
RB_GC_GUARD(vn);
39643961
expo = VpExponent10(vx);
39653962
if (expo < 0 || expo >= 3) {
39663963
char buf[DECIMAL_SIZE_OF_BITS(SIZEOF_VALUE * CHAR_BIT) + 4];
@@ -3975,9 +3972,6 @@ BigMath_s_log(VALUE klass, VALUE x, VALUE vprec)
39753972
x2 = BigDecimal_mult2(x, x, vn);
39763973
y = x;
39773974
d = y;
3978-
RB_GC_GUARD(x2);
3979-
RB_GC_GUARD(y);
3980-
RB_GC_GUARD(d);
39813975
i = 1;
39823976
while (!VpIsZero((Real*)DATA_PTR(d))) {
39833977
SIGNED_VALUE const ey = VpExponent10(DATA_PTR(y));
@@ -4005,6 +3999,13 @@ BigMath_s_log(VALUE klass, VALUE x, VALUE vprec)
40053999
y = BigDecimal_add(y, dy);
40064000
}
40074001

4002+
RB_GC_GUARD(one);
4003+
RB_GC_GUARD(two);
4004+
RB_GC_GUARD(vn);
4005+
RB_GC_GUARD(x2);
4006+
RB_GC_GUARD(y);
4007+
RB_GC_GUARD(d);
4008+
40084009
return y;
40094010
}
40104011

0 commit comments

Comments
 (0)