From: Alexander Borisov Date: Tue, 3 Dec 2019 13:43:04 +0000 (+0300) Subject: Shell: fixed memory leak when empty line is entered. X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=358be5a8145ea022f3338c1266a7e9f74e9be742;p=njs.git Shell: fixed memory leak when empty line is entered. --- 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);