Browse Source

Fixing infinite loop in Array.prototype.reduceRight

Sebastien Ros 12 years ago
parent
commit
14bb688c58
1 changed files with 12 additions and 12 deletions
  1. 12 12
      Jint/Native/Array/ArrayPrototype.cs

+ 12 - 12
Jint/Native/Array/ArrayPrototype.cs

@@ -146,7 +146,7 @@ namespace Jint.Native.Array
                 if (kPresent)
                 if (kPresent)
                 {
                 {
                     var kvalue = o.Get(pk);
                     var kvalue = o.Get(pk);
-                    accumulator = callable.Call(Undefined.Instance, new object[] { accumulator, kvalue, k, o });
+                    accumulator = callable.Call(Undefined.Instance, new [] { accumulator, kvalue, k, o });
                 }
                 }
                 k++;
                 k++;
             }
             }
@@ -179,8 +179,8 @@ namespace Jint.Native.Array
                 if (kpresent)
                 if (kpresent)
                 {
                 {
                     var kvalue = o.Get(pk);
                     var kvalue = o.Get(pk);
-                    var selected = callable.Call(thisArg, new object[] { kvalue, k, o });
-                    if (TypeConverter.ToBoolean(selected) == true)
+                    var selected = callable.Call(thisArg, new [] { kvalue, k, o });
+                    if (TypeConverter.ToBoolean(selected))
                     {
                     {
                         a.DefineOwnProperty(to.ToString(), new DataDescriptor(kvalue) { Writable = true, Enumerable = true, Configurable = true }, false);
                         a.DefineOwnProperty(to.ToString(), new DataDescriptor(kvalue) { Writable = true, Enumerable = true, Configurable = true }, false);
                         to++;
                         to++;
@@ -215,7 +215,7 @@ namespace Jint.Native.Array
                 if (kpresent)
                 if (kpresent)
                 {
                 {
                     var kvalue = o.Get(pk);
                     var kvalue = o.Get(pk);
-                    var mappedValue = callable.Call(thisArg, new object[] { kvalue, k, o });
+                    var mappedValue = callable.Call(thisArg, new [] { kvalue, k, o });
                     a.DefineOwnProperty(pk, new DataDescriptor(mappedValue) { Writable = true, Enumerable = true, Configurable = true }, false);
                     a.DefineOwnProperty(pk, new DataDescriptor(mappedValue) { Writable = true, Enumerable = true, Configurable = true }, false);
                 }
                 }
             }
             }
@@ -245,7 +245,7 @@ namespace Jint.Native.Array
                 if (kpresent)
                 if (kpresent)
                 {
                 {
                     var kvalue = o.Get(pk);
                     var kvalue = o.Get(pk);
-                    callable.Call(thisArg, new object[] { kvalue, k, o });
+                    callable.Call(thisArg, new [] { kvalue, k, o });
                 }
                 }
             }
             }
 
 
@@ -274,8 +274,8 @@ namespace Jint.Native.Array
                 if (kpresent)
                 if (kpresent)
                 {
                 {
                     var kvalue = o.Get(pk);
                     var kvalue = o.Get(pk);
-                    var testResult = callable.Call(thisArg, new object[] { kvalue, k, o });
-                    if (TypeConverter.ToBoolean(testResult) == true)
+                    var testResult = callable.Call(thisArg, new [] { kvalue, k, o });
+                    if (TypeConverter.ToBoolean(testResult))
                     {
                     {
                         return true;
                         return true;
                     }
                     }
@@ -307,8 +307,8 @@ namespace Jint.Native.Array
                 if (kpresent)
                 if (kpresent)
                 {
                 {
                     var kvalue = o.Get(pk);
                     var kvalue = o.Get(pk);
-                    var testResult = callable.Call(thisArg, new object[] { kvalue, k, o });
-                    if (!TypeConverter.ToBoolean(testResult))
+                    var testResult = callable.Call(thisArg, new [] { kvalue, k, o });
+                    if (false == TypeConverter.ToBoolean(testResult))
                     {
                     {
                         return false;
                         return false;
                     }
                     }
@@ -723,7 +723,7 @@ namespace Jint.Native.Array
             var array = TypeConverter.ToObject(Engine, thisObj);
             var array = TypeConverter.ToObject(Engine, thisObj);
             var arrayLen = array.Get("length");
             var arrayLen = array.Get("length");
             var len = TypeConverter.ToUint32(arrayLen);
             var len = TypeConverter.ToUint32(arrayLen);
-            var separator = ",";
+            const string separator = ",";
             if (len == 0)
             if (len == 0)
             {
             {
                 return "";
                 return "";
@@ -841,7 +841,7 @@ namespace Jint.Native.Array
                 throw new JavaScriptException(Engine.TypeError);
                 throw new JavaScriptException(Engine.TypeError);
             }
             }
 
 
-            var k = len - 1;
+            int k = (int)len - 1;
             object accumulator = Undefined.Instance;
             object accumulator = Undefined.Instance;
             if (arguments.Length > 1)
             if (arguments.Length > 1)
             {
             {
@@ -873,7 +873,7 @@ namespace Jint.Native.Array
                 if (kPresent)
                 if (kPresent)
                 {
                 {
                     var kvalue = o.Get(pk);
                     var kvalue = o.Get(pk);
-                    accumulator = callable.Call(Undefined.Instance, new object[] { accumulator, kvalue, k, o });
+                    accumulator = callable.Call(Undefined.Instance, new [] { accumulator, kvalue, k, o });
                 }
                 }
             }
             }