diff --git a/ChangeLog b/ChangeLog index a2ca9bf9bcbe55fddd94f069cb787f7c4a3c7ccc..a85785903e25c4322504d3cbdc3e8b277dc89940 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2016-01-17 Benno Schulenberg <bensberg@justemail.net> * src/global.c: Fix typo in #ifndef symbol. Reported by Frank. * doc/syntax/nanorc.nanorc: Remove '+' as only one menu is allowed. + * src/files.c (load_poshistory): Limit the number of loaded items. 2016-01-17 Mike Frysinger <vapier@gentoo.org> * doc/syntax/nanorc.nanorc: Allow inline comments with key bindings. diff --git a/src/files.c b/src/files.c index b324f6aedb467ae71a9f5708bc3b953a9ffef460..a2104ada9baf3f1dd97b44c76593fe7c0ba957ef 100644 --- a/src/files.c +++ b/src/files.c @@ -3245,7 +3245,7 @@ void load_poshistory(void) } else { char *line = NULL, *lineptr, *xptr; size_t buf_len = 0; - ssize_t read; + ssize_t read, count = 0; poshiststruct *record_ptr = NULL, *newrecord; /* Read and parse each line, and store the extracted data. */ @@ -3271,6 +3271,10 @@ void load_poshistory(void) record_ptr->next = newrecord; record_ptr = newrecord; + + /* Impose a limit, so the file will not grow indefinitely. */ + if (++count > 200) + position_history = position_history->next; } fclose(hist); free(line);