Microsoft KB Archive/219415

= BUG: Incorrect Code Generated by the Cluster Resource Type Wizard =

Article ID: 219415

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft Visual C++ 5.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 5.0 Professional Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition
 * Microsoft Cluster Server 1.1

-



This article was previously published under Q219415



SYMPTOMS
Code generated for the Extension .dll by the Cluster Resource Type Wizard included in the Visual C++ versions listed above may cause an access violation in Cluster Administrator if an error occurs while adding pages to a wizard.



CAUSE
An interface pointer is copied to an object member variable, but AddRef is never called on the interface. If an error occurs in the same method call, the local interface copy is released, but the member variable's copy won't be released. When the object's destructor is called, Release is invoked on the member variable's copy, which raises an access violation.



RESOLUTION
The following code excerpt shows the resolution for this issue:

STDMETHODIMP CExtObject::CreateWizardPages(   IN IUnknown *       piData,    IN IWCWizardCallback *  piCallback    ) {   ...

try {       ...        m_piWizardCallback = piCallback; ...

for ( ... ) {           ...            if (!ppage->BInit(this)) throw &exc; ...

} // for } // try ...

if (hr != NOERROR) {       piCallback->Release;

// The error is here. Because piCallback is saved in        // m_piWizardCallback, the CExtObject destructor // tries to call the Release method on this // interface pointer. Therefore, we need to set that // pointer to NULL. // The following if-block must be added: if (m_piWizardCallback == piCallback) {           m_piWizardCallback = NULL; }

piData->Release; m_piData = NULL; } // if

return hr;

}



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

Keywords: kbbug kbfix kbnoupdate kbprb KB219415

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.