Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-17831

Refcount memory leak in ActiveQt QAxWidget with fix

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 4.6.3, 4.7.1
    • ActiveX Support
    • None
    • Windows XP, Visual C++ 7.1

    Description

      File QAxWidget.cpp, on line 664 (for Qt 4.6.3) has this:

              m_spOleObject->Advise(this, &m_dwOleObject);
              IAdviseSink *spAdviseSink = 0;
              QueryInterface(IID_IAdviseSink, (void**)&spAdviseSink);
              if (spAdviseSink && spViewObject) {
                  if (spViewObject)
                      spViewObject->SetAdvise(DVASPECT_CONTENT, 0, spAdviseSink);
                  spAdviseSink->Release();   <<<<<<<<<<<<<<<<<<<<<<<
              }
              if (spViewObject)
                  spViewObject->Release();
      

      Note the part marked with <<<<<<

      The bug is that the spAdviseSink interface is only released inside the if statement, and that if statement is only taken if both spAdviseSink and spViewObject are not NULL. If spAdviseSink != NULL but spViewObject == NULL then the if will not be taken, and spAdviseSink is never released, leaking that object.

      The fix is to release spAdviseSink below the if statement the same way spViewObject is being released, something like this:

              m_spOleObject->Advise(this, &m_dwOleObject);
              IAdviseSink *spAdviseSink = 0;
              QueryInterface(IID_IAdviseSink, (void**)&spAdviseSink);
              if (spAdviseSink && spViewObject) {
                  if (spViewObject)
                      spViewObject->SetAdvise(DVASPECT_CONTENT, 0, spAdviseSink);
                  // removed spAdviseSink->Release();   <<<<<<<<<<<<<<<<<<<<<<<
              }
              if (spViewObject)
                  spViewObject->Release();
      
              // added
              if (spAdviseSink)
                  spAdviseSink->Release();
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            pullatti Prasanth Ullattil
            michael Michael Gibson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes