From d41ea96c2a844797bc769c9e21c32e97a0c14b69 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sun, 29 Jan 2023 17:10:15 +0900 Subject: [PATCH] string.c: fix boundary check in String#bytesplice It should be able to append to the receiver. --- src/string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/string.c b/src/string.c index 198c3ff9e..df83f2c05 100644 --- a/src/string.c +++ b/src/string.c @@ -2950,7 +2950,7 @@ static mrb_value str_bytesplice(mrb_state *mrb, mrb_value str, mrb_int idx1, mrb_int len1, mrb_value replace, mrb_int idx2, mrb_int len2) { struct RString *s = RSTRING(str); - if (RSTR_LEN(s) <= idx1 || RSTRING_LEN(replace) <= idx2) { + if (RSTR_LEN(s) < idx1 || RSTRING_LEN(replace) < idx2) { mrb_raise(mrb, E_INDEX_ERROR, "index out of string"); } if (RSTR_LEN(s) <= idx1+len1) {