Fixed the crash on opening a buffer