summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--string.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/string.c b/string.c
index 516fc81b93..e4ed93baf8 100644
--- a/string.c
+++ b/string.c
@@ -2640,7 +2640,9 @@ rb_str_format_m(VALUE str, VALUE arg)
VALUE tmp = rb_check_array_type(arg);
if (!NIL_P(tmp)) {
- return rb_str_format(RARRAY_LENINT(tmp), RARRAY_CONST_PTR(tmp), str);
+ VALUE result = rb_str_format(RARRAY_LENINT(tmp), RARRAY_CONST_PTR(tmp), str);
+ RB_GC_GUARD(tmp);
+ return result;
}
return rb_str_format(1, &arg, str);
}