[PATCH 5/7] Close file handle of empty history file

Hannes Domani
2020-05-25T18:57:37Z

Happened while trying to reproduce a gdb.base/gdbinit-history.exp failure:
warning: Could not rename C:/gdb/build64/gdb-git/gdb/testsuite/outputs/gdb.base/gdbinit-history/gdbinit-history.gdb_history to C:/gdb/build64/gdb-git/gdb/testsuite/outputs/gdb.base/gdbinit-history/gdbinit-history.gdb_history-gdb5228~: Permission denied

I had an empty gdbinit-history.gdb_history-gdb5228~ file, and the file
handle was not closed on startup, so it couldn't rename it at the end
when trying to write a new one.

readline/readline/ChangeLog:

2020-05-25 Hannes Domani <ssbssa@yahoo.de>

* histfile.c (read_history_range): Close file handle.
---
readline/readline/histfile.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/readline/readline/histfile.c b/readline/readline/histfile.c
index dc64bde1c5..a8a92aa360 100644
--- a/readline/readline/histfile.c
+++ b/readline/readline/histfile.c
@@ -305,6 +305,7 @@ read_history_range (const char *filename, int from, int to)
if (file_size == 0)
{
free (input);
+ close (file);
return 0; /* don't waste time if we don't have to */
}

--
2.26.2