Fixed undefined behaviour in njs_number_to_integer().

C11: 6.3.1.4
... If the value of the integral part cannot be represented by the
integer type, the behavior is undefined.

Found by OSS-Fuzz.
diff --git a/src/njs_number.h b/src/njs_number.h
index 77d85e3..4753208 100644
--- a/src/njs_number.h
+++ b/src/njs_number.h
@@ -56,18 +56,18 @@
 njs_inline int64_t
 njs_number_to_integer(double num)
 {
-    if (njs_slow_path(isinf(num))) {
-        if (num < 0) {
+    if (njs_fast_path(!isnan(num))) {
+        if (num < INT64_MIN) {
             return INT64_MIN;
+
+        } else if (num > INT64_MAX) {
+            return INT64_MAX;
         }
 
-        return INT64_MAX;
-
-    } else if (njs_slow_path(isnan(num))) {
-        return 0;
+        return num;
     }
 
-    return trunc(num) + 0.0;
+    return 0;
 }
 
 
diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c
index 529eea7..08612da 100644
--- a/src/test/njs_unit_test.c
+++ b/src/test/njs_unit_test.c
@@ -8882,6 +8882,9 @@
     { njs_str("''.repeat(2147483648)"),
       njs_str("") },
 
+    { njs_str("'aaaaaaaa'.repeat(2**64+1)"),
+      njs_str("RangeError") },
+
     { njs_str("''.repeat(Infinity)"),
       njs_str("RangeError") },