[Bug #18956] Negative codepoints are invalid characters

This commit is contained in:
Nobuyoshi Nakada 2022-08-20 01:43:04 +09:00
parent 8f4a53d051
commit d2483393cb
Notes: git 2022-08-20 10:06:37 +09:00
2 changed files with 3 additions and 2 deletions

View file

@ -447,8 +447,8 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
goto format_s1;
}
else {
c = NUM2INT(val);
n = rb_enc_codelen(c, enc);
n = NUM2INT(val);
if (n >= 0) n = rb_enc_codelen((c = n), enc);
}
if (n <= 0) {
rb_raise(rb_eArgError, "invalid character");