[njs] Added missing njs_vm_destroy() calls in CLI.

Dmitry Volyntsev xeioex at nginx.com
Thu Mar 4 13:53:29 UTC 2021


details:   https://hg.nginx.org/njs/rev/52ddc3a050be
branches:  
changeset: 1616:52ddc3a050be
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Wed Mar 03 18:28:00 2021 +0000
description:
Added missing njs_vm_destroy() calls in CLI.

diffstat:

 src/njs_shell.c |  9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diffs (40 lines):

diff -r da49b292dcef -r 52ddc3a050be src/njs_shell.c
--- a/src/njs_shell.c	Fri Feb 26 17:45:56 2021 +0000
+++ b/src/njs_shell.c	Wed Mar 03 18:28:00 2021 +0000
@@ -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_v
         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_v
 
 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, 
         free(line.start);
     }
 
+    njs_vm_destroy(vm);
+
     return NJS_OK;
 }
 


More information about the nginx-devel mailing list