Skip to content

Commit 484ea00

Browse files
nobumatzbot
authored andcommitted
[ruby/stringio] An empty string should be converted to empty in any encoding
ruby/stringio@ef03f9368d
1 parent f513863 commit 484ea00

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

ext/stringio/stringio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,7 @@ strio_ungetc(VALUE self, VALUE c)
961961
}
962962
else {
963963
StringValue(c);
964+
if (RSTRING_LEN(c) == 0) return Qnil;
964965
enc = rb_enc_get(ptr->string);
965966
enc2 = rb_enc_get(c);
966967
if (enc != enc2 && enc != rb_ascii8bit_encoding()) {

0 commit comments

Comments
 (0)