[ruby/date] Prevent converted gregorian date from GC
`m_sf_in_sec` calls `rb_rational_new` that can cause GC. https://github.com/ruby/date/commit/6de449ab6a
This commit is contained in:
parent
d50404d6fe
commit
77e5e06846
@ -8955,18 +8955,22 @@ time_to_datetime(VALUE self)
|
|||||||
static VALUE
|
static VALUE
|
||||||
date_to_time(VALUE self)
|
date_to_time(VALUE self)
|
||||||
{
|
{
|
||||||
|
VALUE t;
|
||||||
|
|
||||||
get_d1a(self);
|
get_d1a(self);
|
||||||
|
|
||||||
if (m_julian_p(adat)) {
|
if (m_julian_p(adat)) {
|
||||||
VALUE tmp = d_lite_gregorian(self);
|
self = d_lite_gregorian(self);
|
||||||
get_d1b(tmp);
|
get_d1b(self);
|
||||||
adat = bdat;
|
adat = bdat;
|
||||||
}
|
}
|
||||||
|
|
||||||
return f_local3(rb_cTime,
|
t = f_local3(rb_cTime,
|
||||||
m_real_year(adat),
|
m_real_year(adat),
|
||||||
INT2FIX(m_mon(adat)),
|
INT2FIX(m_mon(adat)),
|
||||||
INT2FIX(m_mday(adat)));
|
INT2FIX(m_mday(adat)));
|
||||||
|
RB_GC_GUARD(self); /* may be the converted gregorian */
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -9055,6 +9059,7 @@ datetime_to_time(VALUE self)
|
|||||||
f_add(INT2FIX(m_sec(dat)),
|
f_add(INT2FIX(m_sec(dat)),
|
||||||
m_sf_in_sec(dat)),
|
m_sf_in_sec(dat)),
|
||||||
INT2FIX(m_of(dat)));
|
INT2FIX(m_of(dat)));
|
||||||
|
RB_GC_GUARD(self); /* may be the converted gregorian */
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user