NUL-terminate in StringBuffer methods

Even though we keep an explicit length, the String class assumes the
string is also nul-terminated for things like indexOf to work as
expected.