[njs] Fixed import segfault.

Dmitry Volyntsev xeioex at nginx.com
Wed Dec 25 15:24:49 UTC 2019


details:   https://hg.nginx.org/njs/rev/0f31637138ce
branches:  
changeset: 1290:0f31637138ce
user:      hongzhidao <hongzhidao at gmail.com>
date:      Fri Dec 13 12:47:37 2019 +0800
description:
Fixed import segfault.

This closes #274 issue on Github.

diffstat:

 src/njs_module.c    |  1 +
 test/module/lib1.js |  6 ++++++
 2 files changed, 7 insertions(+), 0 deletions(-)

diffs (24 lines):

diff -r 1c3c593cc3fd -r 0f31637138ce src/njs_module.c
--- a/src/njs_module.c	Wed Dec 25 15:59:01 2019 +0300
+++ b/src/njs_module.c	Fri Dec 13 12:47:37 2019 +0800
@@ -175,6 +175,7 @@ njs_parser_module(njs_vm_t *vm, njs_pars
         goto fail;
     }
 
+    module->function.args_offset = 1;
     module->function.u.lambda = parser->node->u.value.data.u.lambda;
 
     njs_mp_free(vm->mem_pool, text.start);
diff -r 1c3c593cc3fd -r 0f31637138ce test/module/lib1.js
--- a/test/module/lib1.js	Wed Dec 25 15:59:01 2019 +0300
+++ b/test/module/lib1.js	Fri Dec 13 12:47:37 2019 +0800
@@ -1,3 +1,9 @@
+var foo = (function(){
+    return (function f() {})
+});
+
+foo()({1:[]})
+
 function hash() {
     var h = crypto.createHash('md5');
     var v = h.update('AB').digest('hex');


More information about the nginx-devel mailing list