Status: Unconfirmed
Owner: [EMAIL PROTECTED]
Labels: Type-Bug Pri-2 OS-All Area-Misc

New issue 5110 by alastairpatrick: npruntime NPN_InvokeDefault forwards to  
invoke instead of invokeDefault
http://code.google.com/p/chromium/issues/detail?id=5110

Chrome Version       : 0.4.154.29
URLs (if applicable) :
Other browsers tested: Firefox 3.0, Firefox 3.1, IE 7
   Add OK or FAIL after other browsers where you have tested this issue:
      Safari 3: Unknown
     Firefox 3: OK
          IE 7: OK

What steps will reproduce the problem?
1. From a plugin using npruntime, create an NPObject implementing both
invoke() and invokeDefault() functions.
2. From within the same plugin, call NPN_InvokeDefault() on that object,
specifying a valid method name (not NULL) and other valid arguments.

What is the expected result?

The object's invokeDefault() function should be called.

What happens instead?

The object's invokeDefault() function is not called. Instead, the object's
invoke() function is called with an invalid (NULL) method name.

Please provide any additional information below. Attach a screenshot if
possible.

I tracked the bug down to this code in src/chrome/plugin/npobject_proxy.cc:

bool NPObjectProxy::NPInvoke(NPObject *obj,
                              NPIdentifier name,
                              const NPVariant *args,
                              uint32_t arg_count,
                              NPVariant *result) {
   return NPInvokePrivate(0, obj, false, name, args, arg_count, result);
}

bool NPObjectProxy::NPInvokeDefault(NPObject *npobj,
                                     const NPVariant *args,
                                     uint32_t arg_count,
                                     NPVariant *result) {
   return NPInvokePrivate(0, npobj, true, 0, args, arg_count, result);
}

bool NPObjectProxy::NPInvokePrivate(NPP npp,
                                     NPObject *obj,
                                     bool is_default,
                                     NPIdentifier name,
                                     const NPVariant *args,
                                     uint32_t arg_count,
                                     NPVariant *np_result) {
   NPObjectProxy* proxy = GetProxy(obj);
   if (!proxy) {
     return obj->_class->invoke(obj, name, args, arg_count, np_result);
   }
   ...

NPInvokePrivate is used to handle calls to both NPInvoke and
NPInvokeDefault. There is a special case for non-NPObjectProxy objects.
However, it does not check the is_default parameter. This causes calls to
NPInvokeDefault to incorrectly forward to invoke() when they should forward
to invokeDefault(). The code should be something like this:

   if (!proxy) {
     if (is_default)
       return obj->_class->invokeDefault(obj, args, arg_count, np_result);
     else
       return obj->_class->invoke(obj, name, args, arg_count, np_result);
   }


-- 
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Chromium-bugs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/chromium-bugs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to