diff options
| author | ZHIJIE XIE <40601688+dummyx@users.noreply.github.com> | 2026-03-03 02:40:57 +0900 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2026-03-03 07:57:17 -0800 |
| commit | a9b84adbd2f30eaefdf2a60341468c00e4bc090c (patch) | |
| tree | 4382f5561ee61d59680c4cce743a9a06771576a6 | |
| parent | aec8563df22fb418566a9806e8b782c38b750f46 (diff) | |
string.c: guard tmp in rb_str_format_m (GH-16280)
[Bug #21931]
Keep tmp alive while RARRAY_CONST_PTR(tmp) is used by rb_str_format.
[alan: sunk the guard below usage]
Reviewed-by: Alan Wu <XrXr@users.noreply.github.com>
| -rw-r--r-- | string.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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); } |
