Bug 532246 - Plugins should not be able to obtain an NPObject* belonging to a different NPP, because that instance may go away before this one and the NPObject* may be invalidated and destroyed. Double-wrap in these cases. r=josh sr=jst

This commit is contained in:
Benjamin Smedberg 2009-12-02 12:02:41 -05:00
parent 0910c44a52
commit 86980c504e

View File

@ -1072,7 +1072,8 @@ nsJSObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, JSObject *obj)
NPObject *npobj = (NPObject *)::JS_GetPrivate(cx, obj);
return _retainobject(npobj);
if (LookupNPP(npobj) == npp)
return _retainobject(npobj);
}
if (!sJSObjWrappers.ops) {
@ -2027,10 +2028,8 @@ static NPP
LookupNPP(NPObject *npobj)
{
if (npobj->_class == &nsJSObjWrapper::sJSObjWrapperNPClass) {
NS_ERROR("NPP requested for NPObject of class "
"nsJSObjWrapper::sJSObjWrapperNPClass!\n");
return nsnull;
nsJSObjWrapper* o = static_cast<nsJSObjWrapper*>(npobj);
return o->mNpp;
}
NPObjWrapperHashEntry *entry = static_cast<NPObjWrapperHashEntry *>