diff --git a/ext/date/date_core.c b/ext/date/date_core.c index 7ed21db..448e969 100644 --- a/ext/date/date_core.c +++ b/ext/date/date_core.c @@ -6985,12 +6985,14 @@ jisx0301_date(VALUE jd, VALUE y) static VALUE d_lite_jisx0301(VALUE self) { - VALUE s; + VALUE s, result; get_d1(self); s = jisx0301_date(m_real_local_jd(dat), m_real_year(dat)); - return strftimev(RSTRING_PTR(s), self, set_tmx); + result = strftimev(RSTRING_PTR(s), self, set_tmx); + RB_GC_GUARD(s); + return result; } #ifndef NDEBUG @@ -8298,7 +8300,7 @@ dt_lite_strftime(int argc, VALUE *argv, VALUE self) static VALUE iso8601_timediv(VALUE self, VALUE n) { - VALUE fmt; + VALUE fmt, result; n = to_integer(n); fmt = rb_usascii_str_new2("T%H:%M:%S"); @@ -8315,7 +8317,9 @@ iso8601_timediv(VALUE self, VALUE n) rb_str_append(fmt, rb_f_sprintf(3, argv)); } rb_str_append(fmt, rb_usascii_str_new2("%:z")); - return strftimev(RSTRING_PTR(fmt), self, set_tmx); + result = strftimev(RSTRING_PTR(fmt), self, set_tmx); + RB_GC_GUARD(fmt); + return result; } /* @@ -8372,7 +8376,7 @@ dt_lite_rfc3339(int argc, VALUE *argv, VALUE self) static VALUE dt_lite_jisx0301(int argc, VALUE *argv, VALUE self) { - VALUE n, s; + VALUE n, s, result; rb_scan_args(argc, argv, "01", &n); @@ -8383,8 +8387,10 @@ dt_lite_jisx0301(int argc, VALUE *argv, VALUE self) get_d1(self); s = jisx0301_date(m_real_local_jd(dat), m_real_year(dat)); - return rb_str_append(strftimev(RSTRING_PTR(s), self, set_tmx), - iso8601_timediv(self, n)); + result = rb_str_append(strftimev(RSTRING_PTR(s), self, set_tmx), + iso8601_timediv(self, n)); + RB_GC_GUARD(s); + return result; } }