Search code examples
c++windowssafarinpapi

Npapi plugin crashes in safari


I developed npapi plugin for Windows. It works in Chrome, Opera, Firefox. But it crashes in Safari. I tried to find stable npapi plugin which works in safari but I didn't find this one.

For example:

1) I get property from plugin fot the first time. It works.

2) But when I try to do it again it fails.

But I see that flash works in Safari. Why? Thank you.

bool CScriptableObject::HasProperty(NPIdentifier name)
{
    ATL::CString strFunc = NPN_UTF8FromIdentifier(name);
    if(!strFunc.CompareNoCase(PROPERTY_VERSION))
    {
        return true;
    }
     return false;
}

bool CScriptableObject::GetProperty(NPIdentifier name, NPVariant *result)
{
       ATL::CString strFunc = NPN_UTF8FromIdentifier(name);
       if(!strFunc.CompareNoCase(PROPERTY_VERSION))
       {
           INT32_TO_NPVARIANT(6, *result);
           return true;
       }
       return false;
}

So, this code works only one time, when I try to get propery "version" from js Safari crashes


Solution

  • I found problem! I looked at source code of Firebreath and understood. It was in code when I return scriptable object in NPP_GetValue. I didn't call NPN_RetainObject. I think Safari released my object and it destroyed.