From f513863c8186ebfbc2a4264929287f982fd147ea Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 26 Oct 2024 21:08:55 +0900 Subject: [PATCH] [ruby/stringio] Unreachable after an invalid argument exception https://github.com/ruby/stringio/commit/a2aab4721c --- ext/stringio/stringio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 863f9ab201..6f68e46cf1 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -952,7 +952,10 @@ strio_ungetc(VALUE self, VALUE c) enc = rb_enc_get(ptr->string); len = rb_enc_codelen(cc, enc); - if (len <= 0) rb_enc_uint_chr(cc, enc); + if (len <= 0) { + rb_enc_uint_chr(cc, enc); /* to raise an exception */ + UNREACHABLE; + } rb_enc_mbcput(cc, buf, enc); return strio_unget_bytes(ptr, buf, len); }