bool xpc_qsStringToJsstring(JSContext *cx, nsString &str, JSString **rval) { // From the T_DOMSTRING case in XPCConvert::NativeData2JS. if (str.IsVoid()) { *rval = nullptr; return true; } nsStringBuffer* sharedBuffer; jsval jsstr = XPCStringConvert::ReadableToJSVal(cx, str, &sharedBuffer); if (JSVAL_IS_NULL(jsstr)) return false; *rval = JSVAL_TO_STRING(jsstr); if (sharedBuffer) { // The string was shared but ReadableToJSVal didn't addref it. // Move the ownership from str to jsstr. str.ForgetSharedBuffer(); } return true; }