From 484ea00d2e1c2f2409cf1b58575cdb2c298c6a45 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 26 Oct 2024 22:13:18 +0900 Subject: [PATCH] [ruby/stringio] An empty string should be converted to empty in any encoding https://github.com/ruby/stringio/commit/ef03f9368d --- ext/stringio/stringio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 6f68e46cf1..4a9cd6f1d9 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -961,6 +961,7 @@ strio_ungetc(VALUE self, VALUE c) } else { StringValue(c); + if (RSTRING_LEN(c) == 0) return Qnil; enc = rb_enc_get(ptr->string); enc2 = rb_enc_get(c); if (enc != enc2 && enc != rb_ascii8bit_encoding()) {