files: don't close a newly-created buffer when it is the only one

This fixes https://savannah.gnu.org/bugs/?56504.
Reported-by: Liu Hao <lh_mouse@126.com>

Bug existed since commit 7e422402 from two weeks ago.
master
Benno Schulenberg 2019-06-16 19:09:03 +02:00
parent c7ca60b046
commit 345cf5accc
1 changed files with 2 additions and 1 deletions

View File

@ -462,7 +462,8 @@ bool open_buffer(const char *filename, bool new_buffer)
/* When not overriding an existing lock, discard the buffer. */ /* When not overriding an existing lock, discard the buffer. */
if (do_lockfile(realname) < 0) { if (do_lockfile(realname) < 0) {
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
close_buffer(); if (openfile != openfile->next)
close_buffer();
#endif #endif
free(realname); free(realname);
return FALSE; return FALSE;