details: https://hg.nginx.org/njs/rev/fa59bcc82142 branches: changeset: 1990:fa59bcc82142 user: Dmitry Volyntsev <xei...@nginx.com> date: Mon Nov 07 14:22:41 2022 -0800 description: Fixed default module loader.
Previously, njs_mp_free() was called with invalid pointer because njs_vm_compile_module() shifts start argument to the last reading position. This closes #601 issue on Github. diffstat: src/njs_module.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diffs (27 lines): diff -r 94b370d9aa13 -r fa59bcc82142 src/njs_module.c --- a/src/njs_module.c Mon Nov 07 14:22:41 2022 -0800 +++ b/src/njs_module.c Mon Nov 07 14:22:41 2022 -0800 @@ -361,10 +361,11 @@ static njs_mod_t * njs_default_module_loader(njs_vm_t *vm, njs_external_ptr_t external, njs_str_t *name) { + u_char *start; njs_int_t ret; njs_str_t cwd, text; + njs_mod_t *module; njs_parser_t *prev; - njs_mod_t *module; njs_module_info_t info; prev = external; @@ -388,7 +389,9 @@ njs_default_module_loader(njs_vm_t *vm, return NULL; } - module = njs_vm_compile_module(vm, &info.file, &text.start, + start = text.start; + + module = njs_vm_compile_module(vm, &info.file, &start, &text.start[text.length]); njs_mp_free(vm->mem_pool, text.start); _______________________________________________ nginx-devel mailing list -- nginx-devel@nginx.org To unsubscribe send an email to nginx-devel-le...@nginx.org