Add an explicit npobject_is_proxy check
For obnoxious reasons, NPN_CreateObject needs to know if an object is a proxy before its proxy fields have been initialized. We can't assume proxy_id == 0 means not a proxy. Valgrind gets upset.
This commit is contained in:
parent
30021085d3
commit
189a5244a3
|
@ -41,6 +41,7 @@ extern NPObject *npobject_lookup_local(uint32_t id) attribute_hidden;
|
|||
// corresponding stub. Holds a reference to the other NPObject on via
|
||||
// its stub.
|
||||
extern NPObject *npobject_create_proxy(NPP npp, uint32_t id) attribute_hidden;
|
||||
extern bool npobject_is_proxy(NPObject *npobj) attribute_hidden;
|
||||
extern uint32_t npobject_get_proxy_id(NPObject *npobj) attribute_hidden;
|
||||
extern void npobject_destroy_proxy(NPObject *npobj, bool release_stub) attribute_hidden;
|
||||
|
||||
|
|
|
@ -153,6 +153,11 @@ NPObject *npobject_create_proxy(NPP instance, uint32_t id)
|
|||
return object;
|
||||
}
|
||||
|
||||
bool npobject_is_proxy(NPObject *npobj)
|
||||
{
|
||||
return npobject_get_proxy(npobj) != NULL;
|
||||
}
|
||||
|
||||
uint32_t npobject_get_proxy_id(NPObject *npobj)
|
||||
{
|
||||
NPObjectProxy *proxy = npobject_get_proxy(npobj);
|
||||
|
|
|
@ -1958,7 +1958,9 @@ g_NPN_CreateObject(NPP instance, NPClass *class)
|
|||
npobj->_class = class;
|
||||
npobj->referenceCount = 1;
|
||||
|
||||
if (npobject_get_proxy_id(npobj) == 0) {
|
||||
// We specifically cannot call npobject_get_proxy_id here because
|
||||
// the proxy has only been allocated, not constructed. (Sigh.)
|
||||
if (!npobject_is_proxy(npobj)) {
|
||||
// Register anything that isn't a proxy.
|
||||
npobject_register(npobj, plugin);
|
||||
if (plugin)
|
||||
|
|
Loading…
Reference in New Issue