]> git.kaiwu.me - njs.git/commitdiff
Shell: fixed memory leak when empty line is entered.
authorAlexander Borisov <alexander.borisov@nginx.com>
Tue, 3 Dec 2019 13:43:04 +0000 (16:43 +0300)
committerAlexander Borisov <alexander.borisov@nginx.com>
Tue, 3 Dec 2019 13:43:04 +0000 (16:43 +0300)
src/njs_shell.c

index 958acb5fa9d92ec229e8ac6179c04cdec0e668a5..d4378990b91a0647e04b65b173a5699267d56834 100644 (file)
@@ -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);