Fix buffer tail bug.