Unverified Commit f4f3ced9 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #4551 from dearblue/fix-4549

Fix heap buffer overflow; ref #4549
parents 93b3b83c 2bb30481
......@@ -1184,7 +1184,7 @@ str_replace_partial(mrb_state *mrb, mrb_value src, mrb_int pos, mrb_int end, mrb
mrb_str_modify(mrb, str);
if (len < newlen || len - newlen >= shrink_threshold) {
if (len < newlen) {
resize_capa(mrb, str, newlen);
}
......@@ -1197,6 +1197,10 @@ str_replace_partial(mrb_state *mrb, mrb_value src, mrb_int pos, mrb_int end, mrb
RSTR_SET_LEN(str, newlen);
strp[newlen] = '\0';
if (len - newlen >= shrink_threshold) {
resize_capa(mrb, str, newlen);
}
return src;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment