Bug 1367791 - Constrain Number.prototype.toFixed precision to be 0 <= p <= 100. (r=jorendorff)
authorShu-yu Guo <shu@rfrn.org>
Fri, 28 Jul 2017 17:43:17 -0700
changeset 420592 03533ecbc1af51dd87edf1419b132a5a254f43a1
parent 420591 11eaa60784b8886d85db57d07404c4285c1b7a98
child 420593 a09d4e4b31bc001d2a050fa311d32fca37b28db4
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1367791
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1367791 - Constrain Number.prototype.toFixed precision to be 0 <= p <= 100. (r=jorendorff) Due to normative change in spec.
js/src/jsnum.cpp
--- a/js/src/jsnum.cpp
+++ b/js/src/jsnum.cpp
@@ -954,17 +954,17 @@ num_toFixed_impl(JSContext* cx, const Ca
     int precision;
     if (args.length() == 0) {
         precision = 0;
     } else {
         double prec = 0;
         if (!ToInteger(cx, args[0], &prec))
             return false;
 
-        if (!ComputePrecisionInRange(cx, -20, MAX_PRECISION, prec, &precision))
+        if (!ComputePrecisionInRange(cx, 0, MAX_PRECISION, prec, &precision))
             return false;
     }
 
     // Step 4.
     if (mozilla::IsNaN(d)) {
         args.rval().setString(cx->names().NaN);
         return true;
     }