From 755b34c5ea539280d91dcadca78b703653aff812 Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Fri, 13 May 2011 19:12:24 +0300 Subject: [PATCH] Bug 656878, nsStringArraySH::GetProperty should not copy, but share strings, r=bz --HG-- extra : rebase_source : 2e7fc8f848042ea7557ea9116f8ec9152869114a --- dom/base/nsDOMClassInfo.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 77b7521903c9..541729839b1b 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -71,7 +71,7 @@ #include "nsIRunnable.h" #include "nsThreadUtils.h" #include "nsDOMEventTargetWrapperCache.h" -#include "xpcpublic.h" +#include "xpcprivate.h" // General helper includes #include "nsGlobalWindow.h" @@ -10201,12 +10201,11 @@ nsStringArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx, JSAutoRequest ar(cx); - JSString *str = - ::JS_NewUCStringCopyN(cx, reinterpret_cast(val.get()), - val.Length()); - NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY); - - *vp = STRING_TO_JSVAL(str); + nsStringBuffer* sharedBuffer = nsnull; + *vp = XPCStringConvert::ReadableToJSVal(cx, val, &sharedBuffer); + if (sharedBuffer) { + val.ForgetSharedBuffer(); + } return NS_SUCCESS_I_DID_SOMETHING; }