Skip to content

Commit

Permalink
Use the same fix as upstream for bigdecimal RB_GC_GUARD
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon authored and john-heinnickel committed Aug 16, 2023
1 parent 52b68e5 commit 783b360
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/main/c/bigdecimal/bigdecimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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));
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 783b360

Please sign in to comment.