diff options
Diffstat (limited to 'libbb/lineedit.c')
-rw-r--r-- | libbb/lineedit.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index c3b5738e2..b3e7abac5 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -1417,15 +1417,19 @@ void FAST_FUNC show_history(const line_input_t *st) | |||
1417 | printf("%4d %s\n", i, st->history[i]); | 1417 | printf("%4d %s\n", i, st->history[i]); |
1418 | } | 1418 | } |
1419 | 1419 | ||
1420 | # if ENABLE_FEATURE_EDITING_SAVEHISTORY | ||
1420 | void FAST_FUNC free_line_input_t(line_input_t *n) | 1421 | void FAST_FUNC free_line_input_t(line_input_t *n) |
1421 | { | 1422 | { |
1422 | # if ENABLE_FEATURE_EDITING_SAVEHISTORY | 1423 | if (n) { |
1423 | int i = n->cnt_history; | 1424 | int i = n->cnt_history; |
1424 | while (i > 0) | 1425 | while (i > 0) |
1425 | free(n->history[--i]); | 1426 | free(n->history[--i]); |
1426 | #endif | 1427 | free(n); |
1427 | free(n); | 1428 | } |
1428 | } | 1429 | } |
1430 | # else | ||
1431 | /* #defined to free() in libbb.h */ | ||
1432 | # endif | ||
1429 | 1433 | ||
1430 | # if ENABLE_FEATURE_EDITING_SAVEHISTORY | 1434 | # if ENABLE_FEATURE_EDITING_SAVEHISTORY |
1431 | /* We try to ensure that concurrent additions to the history | 1435 | /* We try to ensure that concurrent additions to the history |
@@ -1506,7 +1510,7 @@ void save_history(line_input_t *st) | |||
1506 | { | 1510 | { |
1507 | FILE *fp; | 1511 | FILE *fp; |
1508 | 1512 | ||
1509 | if (!st->hist_file) | 1513 | if (!st || !st->hist_file) |
1510 | return; | 1514 | return; |
1511 | if (st->cnt_history <= st->cnt_history_in_file) | 1515 | if (st->cnt_history <= st->cnt_history_in_file) |
1512 | return; | 1516 | return; |