How to handle Bad pointer ( Applcation: IE sidebar as COM Object , VCC++)

Discussion in 'Programming' started by malathiashok, Apr 28, 2009.

  1. #1
    Hi,
    I have my Vertical sidebar with IE. It is causing a problem when I logout of secured sites (https://).

    The history is here:
    There was problem in IR5.0 and that was fixed by a piece of code (under SUPPORT_IE5)in sidebar. The bug was fixed in IE6.0 and sidebar was happy with IE6.0 But now with IE7.0, when I logout of secured sites,
    URL for the below function is passed something link “{????}” by IE (as we can not go to the previous page of some secured site once logged out of it.) So obviously URL -> bstrlVal ends up as a bad pointer.

    Now please suggest me where can I initialize the pointer (URL) as the value to this is passed by IE depending with URL of Main browser address bar and URL of sidebar. It is enough atlease If I could catch the URL when it has NULL Pointer in it.

    Please suggest.


    HRESULT __stdcall BPCompanion:: DocumentComplete(IDispatch* pDisp, VARIANT* URL)
    {
    DEBUG_TRACE("DocumentComplete");

    // Call Script Function
    CallScript(pDisp, CComBSTR(L"BeforeNavigation"));

    if (NULL != URL)
    DEBUG_TRACE("URL %S", URL->bstrVal);

    //IE 5
    #ifdef SUPPORT_IE5
    if (pDisp == m_spWebBrowser)
    {
    if (!URL || CComBSTR(URL->bstrVal) == CComBSTR("about:blank"))
    {
    SetFocus();
    CallScript(pDisp, CComBSTR(L"RHSDocumentComplete"));
    }
    //Baseer: Avoid IE 5 Crash
    //Call NavigateError explicitly
    if (URL){
    if ( wcsstr(URL->bstrVal, L"shdoclc.dll/dnserror.htm#") != NULL ){
    DEBUG_TRACE("Calling NavigateError for IE5.0 crash resolution");
    NavigateError(pDisp, URL);
    }
    }
    }else{
    if (URL){
    Now the code fails here
    & crashes if ( wcsstr(URL->bstrVal, L"bpworldcompanion.dll") != NULL ){
    DEBUG_TRACE("Calling RHSDocumentComplete for IE5.0 crash resolution");
    CallScript(pDisp, CComBSTR(L"RHSDocumentComplete"));
    }
    }

    }
    #else
    if (pDisp == m_spWebBrowser)
    {
    if (!URL || CComBSTR(URL->bstrVal) == CComBSTR("about:blank"))
    {
    SetFocus();
    }
    }
    #endif

    return S_OK;
    }
     
    malathiashok, Apr 28, 2009 IP