Fix memory leaks in String

`String#replace` and `String#clear` have memory leaks bug when self was shared string.

And `String#clear` can to be simple by use fixed `String#replace`.