]> git.kaiwu.me - njs.git/commitdiff
Fixed error handling of setting non-numeric Array.length.
authorValentin Bartenev <vbart@nginx.com>
Sat, 30 Jun 2018 17:39:22 +0000 (20:39 +0300)
committerValentin Bartenev <vbart@nginx.com>
Sat, 30 Jun 2018 17:39:22 +0000 (20:39 +0300)
njs/njs_array.c

index 2df66b06ba66b44af688f3dbb0d0ecd133a18a56..8b41993f0f7634c6c6f7b6e76e4858335f91250a 100644 (file)
@@ -375,6 +375,11 @@ njs_array_prototype_length(njs_vm_t *vm, njs_value_t *value,
     array = value->data.u.array;
 
     if (setval != NULL) {
+        if (!njs_is_number(setval)) {
+            njs_range_error(vm, "Invalid array length");
+            return NJS_ERROR;
+        }
+
         num = setval->data.u.number;
         length = (uint32_t) num;