mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Need to call mrb_str_modify() in mrb_str_cat_str(); fix #4018
If `str` and `str2` are the same string object `str->ptr` may be rewritten by `mrb_str_modify()`.
This commit is contained in:
@@ -2615,6 +2615,9 @@ mrb_str_cat_cstr(mrb_state *mrb, mrb_value str, const char *ptr)
|
||||
MRB_API mrb_value
|
||||
mrb_str_cat_str(mrb_state *mrb, mrb_value str, mrb_value str2)
|
||||
{
|
||||
if (mrb_str_ptr(str) == mrb_str_ptr(str2)) {
|
||||
mrb_str_modify(mrb, mrb_str_ptr(str));
|
||||
}
|
||||
return mrb_str_cat(mrb, str, RSTRING_PTR(str2), RSTRING_LEN(str2));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user