diff -r cc96f8c51ec0 src/NpapiPlugin/NPObjectAPI.cpp
--- a/src/NpapiPlugin/NPObjectAPI.cpp	Thu Jul 15 13:49:51 2010 -0600
+++ b/src/NpapiPlugin/NPObjectAPI.cpp	Wed Jul 21 22:03:17 2010 +0300
@@ -21,6 +21,8 @@
     : BrowserObjectAPI(h), browser(h), obj(o)
 {
     if (h != NULL && o != NULL) {
+        // Do a double-retain to detect browser errors
+        browser->RetainObject(obj);
         browser->RetainObject(obj);
     }
 }
@@ -28,7 +30,23 @@
 NPObjectAPI::~NPObjectAPI(void)
 {
     if (browser.ptr() != NULL && obj != NULL) {
-        browser->ReleaseObject(obj);
+        if(obj->referenceCount < 2) {
+            printf("NPObjectAPI: Buggy browser detected: our RetainObject was not honoured\n");
+            /* In theory we could check if referenceCount == 1 and
+             * do a release, but in practice this will cause Firefox 
+             * to crash at times. According to common sense, it's not a good idea
+             * to try to Release something that has it's reference count
+             * fucked up already: a potential memory leak is a lot better
+             * than a crash so we just leave it alone. */
+        } else {
+            browser->ReleaseObject(obj);
+            if(obj->referenceCount < 1) {
+                printf("NPObjectAPI(): Buggy browser detected: race condition in ReleaseObject\n");
+            } else {
+                browser->ReleaseObject(obj);
+            }
+        }
+        obj = NULL;
     }
 }
 
@@ -148,4 +166,4 @@
         browser->ReleaseVariantValue(&retVal);  // Always release the return value!
         return ret;
     }
-}
\ No newline at end of file
+}
diff -r cc96f8c51ec0 src/NpapiPlugin/NpapiPluginModule_NPP.cpp
--- a/src/NpapiPlugin/NpapiPluginModule_NPP.cpp	Thu Jul 15 13:49:51 2010 -0600
+++ b/src/NpapiPlugin/NpapiPluginModule_NPP.cpp	Wed Jul 21 22:03:17 2010 +0300
@@ -112,8 +112,6 @@
 NPError NpapiPluginModule::NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc,
                                    char* argn[], char* argv[], NPSavedData* saved)
 {
-    printf("NPP_New()\n");
-    
     if (instance == NULL) {
         return NPERR_INVALID_INSTANCE_ERROR;
     }

Add an experimental patch to windows build
esteid-browser-plugin: Add an experimental patch to windows build


git-svn-id: 804e3bcc3d5e1f71d31da0afe626cb969e0fc117@2925 0d7e1ef0-d974-fc83-f0b3-ccc071561e0e
