Fixed memory allocation issue when the repalcement text is considerably
longer than the match text.