Bug 1389974 - Rooting fixes for nsJSNPRuntime.cpp, r=froydnj

--HG--
extra : rebase_source : 24af0cf16c2de4eb06ea81aab09fa71021ff3e16
extra : histedit_source : 65893418fbe37a5a7384c70c7b331c8a5314b8e9
This commit is contained in:
Steve Fink 2017-09-01 08:28:38 -07:00
Родитель a81be745e7
Коммит e58fb2d703
1 изменённых файлов: 12 добавлений и 5 удалений

Просмотреть файл

@ -248,7 +248,8 @@ static bool
NPObjWrapper_toPrimitive(JSContext *cx, unsigned argc, JS::Value *vp);
static bool
CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject* npobj,
CreateNPObjectMember(NPP npp, JSContext *cx,
JS::Handle<JSObject*> obj, NPObject* npobj,
JS::Handle<jsid> id, NPVariant* getPropertyResult,
JS::MutableHandle<JS::Value> vp);
@ -1173,9 +1174,10 @@ nsJSObjWrapper::GetNewOrUsed(NPP npp, JS::Handle<JSObject*> obj)
// compartment for callers that plan to hold onto the result or do anything
// substantial with it.
static JSObject *
GetNPObjectWrapper(JSContext *cx, JSObject *aObj, bool wrapResult = true)
GetNPObjectWrapper(JSContext *cx, JS::Handle<JSObject*> aObj, bool wrapResult = true)
{
JS::Rooted<JSObject*> obj(cx, aObj);
while (obj && (obj = js::CheckedUnwrap(obj))) {
if (nsNPObjWrapper::IsWrapper(obj)) {
if (wrapResult && !JS_WrapObject(cx, &obj)) {
@ -1193,8 +1195,9 @@ GetNPObjectWrapper(JSContext *cx, JSObject *aObj, bool wrapResult = true)
}
static NPObject *
GetNPObject(JSContext *cx, JSObject *obj)
GetNPObject(JSContext *cx, JS::Handle<JSObject*> aObj)
{
JS::Rooted<JSObject*> obj(cx, aObj);
obj = GetNPObjectWrapper(cx, obj, /* wrapResult = */ false);
if (!obj) {
return nullptr;
@ -2129,7 +2132,8 @@ LookupNPP(NPObject *npobj)
}
static bool
CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject* npobj,
CreateNPObjectMember(NPP npp, JSContext *cx,
JS::Handle<JSObject*> aObj, NPObject* npobj,
JS::Handle<jsid> id, NPVariant* getPropertyResult,
JS::MutableHandle<JS::Value> vp)
{
@ -2149,6 +2153,8 @@ CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject* npobj,
// during initialization.
memset(memberPrivate, 0, sizeof(NPObjectMemberPrivate));
JS::Rooted<JSObject*> obj(cx, aObj);
JS::Rooted<JSObject*> memobj(cx, ::JS_NewObject(cx, &sNPObjectMemberClass));
if (!memobj) {
free(memberPrivate);
@ -2234,7 +2240,8 @@ NPObjectMember_Call(JSContext *cx, unsigned argc, JS::Value *vp)
if (!memberPrivate || !memberPrivate->npobjWrapper)
return false;
NPObject *npobj = GetNPObject(cx, memberPrivate->npobjWrapper);
JS::Rooted<JSObject*> objWrapper(cx, memberPrivate->npobjWrapper);
NPObject *npobj = GetNPObject(cx, objWrapper);
if (!npobj) {
ThrowJSExceptionASCII(cx, "Call on invalid member object");