diff options
Diffstat (limited to 'src/history.c')
| -rw-r--r-- | src/history.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/history.c b/src/history.c index 028745e..511f12a 100644 --- a/src/history.c +++ b/src/history.c @@ -151,7 +151,8 @@ void lush_push_history(const char *line) { fprintf(fp, "%s\n", line); // Write the last MAX_LINES lines - for (int i = 0; i < MAX_LINES; i++) { + int total_lines = line_count < MAX_LINES ? line_count : MAX_LINES; + for (int i = 0; i < total_lines; i++) { fprintf(fp, "%s", lines[i]); free(lines[i]); // Free each line after writing } |
