On Mon, 28 Nov 2005, Richard Bell wrote:
> I'm trying to make some enhancements to Win32::IE::Mechanize that
> involve (in part) blocking popups. Several online examples suggest
> catching the NewWindow event and setting cancel true. When I attempt
> to do so I get Win32::OLE crashes. I've included an example program
> that exhibits the issue on my machines:

Thanks for the report!  This is a bug in Win32::OLE.  Here is a fix:

--- OLE.xs.~1~  Mon Nov 28 16:15:09 2005
+++ OLE.xs      Mon Nov 28 16:15:09 2005
@@ -2306,10 +2306,12 @@
             SysFreeString(*V_BSTRREF(pVariant));
             break;
         case VT_DISPATCH:
-            (*V_DISPATCHREF(pVariant))->Release();
+            if (*V_DISPATCHREF(pVariant))
+                (*V_DISPATCHREF(pVariant))->Release();
             break;
         case VT_UNKNOWN:
-            (*V_UNKNOWNREF(pVariant))->Release();
+            if (*V_UNKNOWNREF(pVariant))
+                (*V_UNKNOWNREF(pVariant))->Release();
             break;
         }
         VariantInit(pVariant);
End of Patch.

With the patch applied, the crash goes away and all popups are blocked.
Of course I first had to disable popup blockers in IE itself, and in the
Google toolbar before I could even see the problem...

Cheers,
-Jan

PS: Please don't use HTML email, especially if you include source samples. 



Reply via email to