From 358be5a8145ea022f3338c1266a7e9f74e9be742 Mon Sep 17 00:00:00 2001 From: Alexander Borisov Date: Tue, 3 Dec 2019 16:43:04 +0300 Subject: [PATCH] Shell: fixed memory leak when empty line is entered. --- src/njs_shell.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/njs_shell.c b/src/njs_shell.c index 958acb5f..d4378990 100644 --- a/src/njs_shell.c +++ b/src/njs_shell.c @@ -869,13 +869,12 @@ njs_interactive_shell(njs_opts_t *opts, njs_vm_opt_t *vm_options) } line.length = njs_strlen(line.start); - if (line.length == 0) { - continue; - } - add_history((char *) line.start); + if (line.length != 0) { + add_history((char *) line.start); - njs_process_script(opts, vm_options->external, &line); + njs_process_script(opts, vm_options->external, &line); + } /* editline allocs a new buffer every time. */ free(line.start); -- 2.47.3