[ruby/stringio] Unreachable after an invalid argument exception

https://github.com/ruby/stringio/commit/a2aab4721c
This commit is contained in:
Nobuyoshi Nakada 2024-10-26 21:08:55 +09:00 committed by git
parent 393c5df008
commit f513863c81

View File

@ -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);
}