From d3fdcf994cf0b3878e67f5f86398990f5c30b322 Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Wed, 3 Mar 2021 18:28:00 +0000 Subject: [PATCH] Added missing njs_vm_destroy() calls in CLI. --- src/njs_shell.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/njs_shell.c b/src/njs_shell.c index 8c5cf679..1a49f04b 100644 --- a/src/njs_shell.c +++ b/src/njs_shell.c @@ -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; } -- 2.47.3