Skip to content

Commit

Permalink
Treat NULL fake string as an empty string
Browse files Browse the repository at this point in the history
And the NULL string must be of size 0.
  • Loading branch information
nobu committed Aug 17, 2021
1 parent 21fd83a commit edf01d4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions string.c
Expand Up @@ -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;
/* 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);
Expand Down

0 comments on commit edf01d4

Please sign in to comment.