Bug 921399 - Fix memory leak. r=gabor
authorBobby Holley <bobbyholley@gmail.com>
Fri, 27 Sep 2013 18:34:24 +0200
changeset 149012 6b8e91bf52b637c04d37f92fd7fae0e01924640c
parent 149011 01198082967c5934ec7c67e25ec4efb178770582
child 149013 f0fad858e878f144ddc875515ea8f0b025d94af2
push id25366
push userkwierso@gmail.com
push dateSat, 28 Sep 2013 02:13:38 +0000
treeherdermozilla-central@e1914e294152 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs921399
milestone27.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 921399 - Fix memory leak. r=gabor
js/xpconnect/src/Sandbox.cpp
--- a/js/xpconnect/src/Sandbox.cpp
+++ b/js/xpconnect/src/Sandbox.cpp
@@ -879,27 +879,27 @@ xpc::SandboxOptions::GlobalProperties::P
     uint32_t length;
     bool ok = JS_GetArrayLength(cx, obj, &length);
     NS_ENSURE_TRUE(ok, false);
     for (uint32_t i = 0; i < length; i++) {
         RootedValue nameValue(cx);
         ok = JS_GetElement(cx, obj, i, &nameValue);
         NS_ENSURE_TRUE(ok, false);
         NS_ENSURE_TRUE(nameValue.isString(), false);
-        char *name = JS_EncodeString(cx, nameValue.toString());
+        JSAutoByteString name(cx, nameValue.toString());
         NS_ENSURE_TRUE(name, false);
-        if (!strcmp(name, "XMLHttpRequest")) {
+        if (!strcmp(name.ptr(), "XMLHttpRequest")) {
             XMLHttpRequest = true;
-        } else if (!strcmp(name, "TextEncoder")) {
+        } else if (!strcmp(name.ptr(), "TextEncoder")) {
             TextEncoder = true;
-        } else if (!strcmp(name, "TextDecoder")) {
+        } else if (!strcmp(name.ptr(), "TextDecoder")) {
             TextDecoder = true;
-        } else if (!strcmp(name, "atob")) {
+        } else if (!strcmp(name.ptr(), "atob")) {
             atob = true;
-        } else if (!strcmp(name, "btoa")) {
+        } else if (!strcmp(name.ptr(), "btoa")) {
             btoa = true;
         } else {
             // Reporting error, if one of the global property names is unknown.
             return false;
         }
     }
     return true;
 }