Fix buffer collapse bug in string decoding