diff --git a/src/npruntime-impl.h b/src/npruntime-impl.h index d3595b1..4adca89 100644 --- a/src/npruntime-impl.h +++ b/src/npruntime-impl.h @@ -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; diff --git a/src/npruntime.c b/src/npruntime.c index b4776d7..e6ddac1 100644 --- a/src/npruntime.c +++ b/src/npruntime.c @@ -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); diff --git a/src/npw-viewer.c b/src/npw-viewer.c index ccfa95f..a84e8bc 100644 --- a/src/npw-viewer.c +++ b/src/npw-viewer.c @@ -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)