Fix a potential problem when moving between buffers