summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorNAKAMURA Usaku <usa@ruby-lang.org>2022-07-25 20:39:12 +0900
committerNAKAMURA Usaku <usa@ruby-lang.org>2022-07-25 20:39:12 +0900
commit9733f4d0f00a38b5f77ee2e2fffdff866828cd66 (patch)
tree0bdd070c39d5c0d1869f66572c282809bb72eab7 /string.c
parent6ac4449fce6257ffe653a743880cead2e43167e8 (diff)
merge revision(s) edf01d4e82d8e44ee30ec41fbcb7f802bc8b8c5d: [Backport #18772]
Treat NULL fake string as an empty string And the NULL string must be of size 0. --- string.c | 5 +++++ 1 file changed, 5 insertions(+)
Diffstat (limited to 'string.c')
-rw-r--r--string.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/string.c b/string.c
index 4d55406dea..8f2a937758 100644
--- a/string.c
+++ b/string.c
@@ -414,6 +414,11 @@ setup_fake_str(struct RString *fake_str, const char *name, long len, int encidx)
fake_str->basic.flags = T_STRING|RSTRING_NOEMBED|STR_NOFREE|STR_FAKESTR;
/* SHARED to be allocated by the callback */
+ if (!name) {
+ RUBY_ASSERT_ALWAYS(len == 0);
+ name = "";
+ }
+
ENCODING_SET_INLINED((VALUE)fake_str, encidx);
RBASIC_SET_CLASS_RAW((VALUE)fake_str, rb_cString);