1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Treat NULL fake string as an empty string

And the NULL string must be of size 0.
This commit is contained in:
Nobuyoshi Nakada 2021-08-17 18:45:36 +09:00
parent 21fd83a823
commit edf01d4e82
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

View file

@ -413,6 +413,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; fake_str->basic.flags = T_STRING|RSTRING_NOEMBED|STR_NOFREE|STR_FAKESTR;
/* SHARED to be allocated by the callback */ /* SHARED to be allocated by the callback */
if (!name) {
RUBY_ASSERT_ALWAYS(len == 0);
name = "";
}
ENCODING_SET_INLINED((VALUE)fake_str, encidx); ENCODING_SET_INLINED((VALUE)fake_str, encidx);
RBASIC_SET_CLASS_RAW((VALUE)fake_str, rb_cString); RBASIC_SET_CLASS_RAW((VALUE)fake_str, rb_cString);