Commit 862f3c39 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #537 from iij/pr-adjust-length-after-chomp

adjust string length after String#chomp!
parents 1c95f4eb d090f3ee
......@@ -939,6 +939,7 @@ mrb_str_chomp_bang(mrb_state *mrb, mrb_value str)
else {
return mrb_nil_value();
}
s->ptr[s->len] = '\0';
return str;
}
......@@ -970,7 +971,7 @@ mrb_str_chomp_bang(mrb_state *mrb, mrb_value str)
(rslen <= 1 ||
memcmp(RSTRING_PTR(rs), pp, rslen) == 0)) {
s->len = len - rslen;
p[len] = '\0';
p[s->len] = '\0';
return str;
}
return mrb_nil_value();
......
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