Fix a buffer boundary case when there's no item to flush