diff --git a/cli/completion.c b/cli/completion.c index 444d6631..440f905d 100644 --- a/cli/completion.c +++ b/cli/completion.c @@ -323,6 +323,8 @@ readinput(const char *instruction, const char *old_tmp, char **new_tmp) } } +cleanup: + if (new_tmp) { *new_tmp = tmpname; } else { @@ -330,8 +332,6 @@ readinput(const char *instruction, const char *old_tmp, char **new_tmp) free(tmpname); } -cleanup: - close(tmpfd); free(old_content); diff --git a/cli/linenoise/linenoise.c b/cli/linenoise/linenoise.c index 2bb6a13f..3764b2d7 100644 --- a/cli/linenoise/linenoise.c +++ b/cli/linenoise/linenoise.c @@ -1044,8 +1044,10 @@ char *linenoiseHistoryDataGet() { static void linenoiseHistItemFree(int hist_idx) { free(history[hist_idx].line); + history[hist_idx].line = NULL; if (hist_data_free_clb) { hist_data_free_clb(history[hist_idx].data); + history[hist_idx].data = NULL; } }