Bug 898734 - Fix segfault in error handling. r=nmatsakis
authorNikhil Marathe <nsm.nikhil@gmail.com>
Mon, 29 Jul 2013 10:28:03 -0700
changeset 152705 4e20058bb808195442a0ceb174a1c4314ce5bc6c
parent 152704 7e79de7e28408cbbf40a31abbda3fb17f2286a32
child 152706 1d7b0ea3baa08f607c4133ba5b39f2a8df92b54f
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnmatsakis
bugs898734
milestone25.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 898734 - Fix segfault in error handling. r=nmatsakis
js/src/builtin/BinaryData.cpp
js/src/tests/ecma_6/BinaryData/numerictypes.js
--- a/js/src/builtin/BinaryData.cpp
+++ b/js/src/builtin/BinaryData.cpp
@@ -405,20 +405,18 @@ NumericType<T>::convert(JSContext *cx, H
 }
 
 template <typename T>
 JSBool
 NumericType<T>::call(JSContext *cx, unsigned argc, Value *vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     if (args.length() < 1) {
-        char *fnName = JS_EncodeString(cx, args.callee().as<JSFunction>().atom());
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_MORE_ARGS_NEEDED,
-                             fnName, "0", "s");
-        JS_free(cx, (void *) fnName);
+                             args.callee().getClass()->name, "0", "s");
         return false;
     }
 
     RootedValue arg(cx, args[0]);
     T answer;
     if (!convert(cx, arg, &answer))
         return false; // convert() raises TypeError.
 
--- a/js/src/tests/ecma_6/BinaryData/numerictypes.js
+++ b/js/src/tests/ecma_6/BinaryData/numerictypes.js
@@ -80,16 +80,17 @@ function runTests()
         check(function() type.toString() === strings[i]);
         check(function() type(null) == 0);
         check(function() type(undefined) == 0);
         check(function() type([]) == 0);
         check(function() type({}) == 0);
         check(function() type(/abcd/) == 0);
 
         checkThrows(function() new type());
+        checkThrows(function() type());
     }
 
     var floatTypes = [float32, float64];
     var floatStrings = ["float32", "float64"];
     for (var i = 0; i < floatTypes.length; i++) {
         var type = floatTypes[i];
 
         check(function() type(true) === 1);
@@ -100,16 +101,17 @@ function runTests()
         check(function() type.toString() === floatStrings[i]);
         check(function() type(null) == 0);
         check(function() Number.isNaN(type(undefined)));
         check(function() Number.isNaN(type([])));
         check(function() Number.isNaN(type({})));
         check(function() Number.isNaN(type(/abcd/)));
 
         checkThrows(function() new type());
+        checkThrows(function() type());
     }
 
     ///// test ranges and creation
     /// uint8
     // valid
     check(function() uint8(0) == 0);
     check(function() uint8(-0) == 0);
     check(function() uint8(129) == 129);