Bug 756897 - Don't use XPCStringConvert::ReadableToJSVal directly in nsDOMClassInfo.cpp; r=bz
authorMs2ger <ms2ger@gmail.com>
Tue, 02 Oct 2012 10:24:10 +0200
changeset 108921 3c6284e55b87d2e11f4a187bc41567db19cf83f0
parent 108920 ee22f4c023e2549eeaf408391727a79c50bd448a
child 108922 8dcf029847f944bb566dcdc9a56667626fd3d86d
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersbz
bugs756897
milestone18.0a1
Bug 756897 - Don't use XPCStringConvert::ReadableToJSVal directly in nsDOMClassInfo.cpp; r=bz
dom/base/nsDOMClassInfo.cpp
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -8624,22 +8624,18 @@ nsDOMStringMapSH::GetProperty(nsIXPConne
   nsresult rv = dataset->GetDataAttr(propName, propVal);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (propVal.IsVoid()) {
     *vp = JSVAL_VOID;
     return NS_SUCCESS_I_DID_SOMETHING;
   }
 
-  nsStringBuffer* valBuf;
-  *vp = XPCStringConvert::ReadableToJSVal(cx, propVal, &valBuf);
-  if (valBuf) {
-    propVal.ForgetSharedBuffer();
-  }
-
+  NS_ENSURE_TRUE(xpc::NonVoidStringToJsval(cx, propVal, vp),
+                 NS_ERROR_OUT_OF_MEMORY);
   return NS_SUCCESS_I_DID_SOMETHING;
 }
 
 NS_IMETHODIMP
 nsDOMStringMapSH::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
                               JSObject *obj, jsid id, jsval *vp,
                               bool *_retval)
 {
@@ -10207,24 +10203,21 @@ nsStringArraySH::GetProperty(nsIXPConnec
 
   nsresult rv = GetStringAt(GetNative(wrapper, obj), n, val);
   NS_ENSURE_SUCCESS(rv, rv);
 
   JSAutoRequest ar(cx);
 
   if (DOMStringIsNull(val)) {
     *vp = JSVAL_VOID;
-  } else {
-    nsStringBuffer* sharedBuffer = nullptr;
-    *vp = XPCStringConvert::ReadableToJSVal(cx, val, &sharedBuffer);
-    if (sharedBuffer) {
-      val.ForgetSharedBuffer();
-    }
-  }
-
+    return NS_SUCCESS_I_DID_SOMETHING;
+  }
+
+  NS_ENSURE_TRUE(xpc::NonVoidStringToJsval(cx, val, vp),
+                 NS_ERROR_OUT_OF_MEMORY);
   return NS_SUCCESS_I_DID_SOMETHING;
 }
 
 
 // History helper
 
 NS_IMETHODIMP
 nsHistorySH::PreCreate(nsISupports *nativeObj, JSContext *cx,