]> git.kaiwu.me - njs.git/commitdiff
Fixed null pointer dereferences introduced in f5bdddca3252.
authorDmitry Volyntsev <xeioex@nginx.com>
Sat, 27 Apr 2019 17:28:37 +0000 (20:28 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Sat, 27 Apr 2019 17:28:37 +0000 (20:28 +0300)
CID 1444775, CID 1444776.

njs/njs_array.c
njs/njs_function.c

index 934f6256cc1688b7a841365fbf1d5590d2862e4d..3394dcbad4698426f07cb280aa38987eecbc587b 100644 (file)
@@ -432,6 +432,11 @@ njs_array_length(njs_vm_t *vm, njs_value_t *value, njs_value_t *setval,
         proto = proto->__proto__;
     } while (proto != NULL);
 
+    if (nxt_slow_path(proto == NULL)) {
+        njs_internal_error(vm, "no array in proto chain");
+        return NJS_ERROR;
+    }
+
     array = (njs_array_t *) proto;
 
     if (setval != NULL) {
index c60e32492005a6f1bf5f4249d8f5c64e528e1736..f1743cd24137b4b6ce190d97bc848ef9c3e10968 100644 (file)
@@ -921,6 +921,11 @@ njs_function_instance_length(njs_vm_t *vm, njs_value_t *value,
         proto = proto->__proto__;
     } while (proto != NULL);
 
+    if (nxt_slow_path(proto == NULL)) {
+        njs_internal_error(vm, "no function in proto chain");
+        return NJS_ERROR;
+    }
+
     function = (njs_function_t *) proto;
 
     if (function->native) {