]> git.kaiwu.me - njs.git/commitdiff
Fixed integer overflow in njs_typed_array_constructor().
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 9 Jan 2020 12:54:52 +0000 (15:54 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Thu, 9 Jan 2020 12:54:52 +0000 (15:54 +0300)
Found by Coverity (CID 1457371).

src/njs_typed_array.c

index 9d4c482c823d2d722dec939a4f79b1676b8caa1f..a7d683d0435ab9841e4b221fb214445fa86e980b 100644 (file)
@@ -85,7 +85,7 @@ njs_typed_array_constructor(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
 
     } else if (njs_is_typed_array(value)) {
         src_tarray = njs_typed_array(value);
-        size = njs_typed_array_length(src_tarray) * element_size;
+        size = (uint64_t) njs_typed_array_length(src_tarray) * element_size;
 
     } else if (njs_is_object(value)) {
         if (njs_is_array(value) && njs_object_hash_is_empty(value)) {