From 37490474c4bd45572c0bb35506dc6e032c8ebfd2 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Fri, 5 Apr 2024 16:14:24 -0400 Subject: [PATCH] Assert that rb_sym2str returns 0 or a T_STRING --- symbol.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/symbol.c b/symbol.c index 052cc2d3ee..7be0a61a75 100644 --- a/symbol.c +++ b/symbol.c @@ -953,12 +953,17 @@ rb_id2sym(ID x) VALUE rb_sym2str(VALUE sym) { + VALUE str; if (DYNAMIC_SYM_P(sym)) { - return RSYMBOL(sym)->fstr; + str = RSYMBOL(sym)->fstr; + RUBY_ASSERT(BUILTIN_TYPE(str) == T_STRING); } else { - return rb_id2str(STATIC_SYM2ID(sym)); + str = rb_id2str(STATIC_SYM2ID(sym)); + RUBY_ASSERT(str == 0 || BUILTIN_TYPE(str) == T_STRING); } + + return str; } VALUE