]> git.kaiwu.me - njs.git/commitdiff
Added missing njs_vm_destroy() calls in CLI.
authorDmitry Volyntsev <xeioex@nginx.com>
Wed, 3 Mar 2021 18:28:00 +0000 (18:28 +0000)
committerDmitry Volyntsev <xeioex@nginx.com>
Wed, 3 Mar 2021 18:28:00 +0000 (18:28 +0000)
src/njs_shell.c

index 8c5cf6792758325b45aa0d4bcd0a6fc8c8de930b..1a49f04b6da78b18a523e8c5a4e32471ba571fc8 100644 (file)
@@ -282,6 +282,7 @@ main(int argc, char **argv)
             command.start = (u_char *) opts.command;
             command.length = njs_strlen(opts.command);
             ret = njs_process_script(&opts, vm_options.external, &command);
+            njs_vm_destroy(vm);
         }
 
     } else {
@@ -498,6 +499,8 @@ njs_process_file(njs_opts_t *opts, njs_vm_opt_t *vm_options)
         size = sb.st_size;
     }
 
+    vm = NULL;
+
     source.length = 0;
     source.start = realloc(NULL, size);
     if (source.start == NULL) {
@@ -577,6 +580,10 @@ njs_process_file(njs_opts_t *opts, njs_vm_opt_t *vm_options)
 
 done:
 
+    if (vm != NULL) {
+        njs_vm_destroy(vm);
+    }
+
     if (source.start != NULL) {
         free(source.start);
     }
@@ -938,6 +945,8 @@ njs_interactive_shell(njs_opts_t *opts, njs_vm_opt_t *vm_options)
         free(line.start);
     }
 
+    njs_vm_destroy(vm);
+
     return NJS_OK;
 }