From f1f9c63cdb4d675d752e2eb3cb520a8fe43f3632 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 23 Feb 2026 09:12:57 +0000 Subject: [PATCH] Free history entries properly, from Huihui Huang in GitHub issue 4870. --- cmd-show-prompt-history.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd-show-prompt-history.c b/cmd-show-prompt-history.c index 1b95bcaf..5b88499c 100644 --- a/cmd-show-prompt-history.c +++ b/cmd-show-prompt-history.c @@ -60,6 +60,9 @@ cmd_show_prompt_history_exec(struct cmd *self, struct cmdq_item *item) if (cmd_get_entry(self) == &cmd_clear_prompt_history_entry) { if (typestr == NULL) { for (tidx = 0; tidx < PROMPT_NTYPES; tidx++) { + for (hidx = 0; hidx < status_prompt_hsize[tidx]; + hidx++) + free(status_prompt_hlist[tidx][hidx]); free(status_prompt_hlist[tidx]); status_prompt_hlist[tidx] = NULL; status_prompt_hsize[tidx] = 0; @@ -70,6 +73,8 @@ cmd_show_prompt_history_exec(struct cmd *self, struct cmdq_item *item) cmdq_error(item, "invalid type: %s", typestr); return (CMD_RETURN_ERROR); } + for (hidx = 0; hidx < status_prompt_hsize[type]; hidx++) + free(status_prompt_hlist[type][hidx]); free(status_prompt_hlist[type]); status_prompt_hlist[type] = NULL; status_prompt_hsize[type] = 0;