Article ID: 131102
Article Last Modified on 8/16/2005
BOOL CEnumConnPoints::OnNext(void FAR* pv)
{
if (!CEnumArray::OnNext(pv))
return FALSE;
// outgoing connection point needs to be AddRef'ed
// (the caller has responsibility to release it)
((LPCONNECTIONPOINT)pv)->AddRef();
return TRUE;
}
AddRef() is called through an improperly dereferenced pointer. The line of
code should be this:
(*(LPCONNECTIONPOINT*)pv)->AddRef();
void CControlContainerView::OnEnumCtrlConnPoints()
{
if (!m_pSelection) // pointer to a COleClientItem derived object
// that supports additional OLE Control interfaces
{
AfxMessageBox(_T("No Control selected!"));
return;
}
LPCONNECTIONPOINTCONTAINER lpCPC;
LPENUMCONNECTIONPOINTS lpEnumCPTS;
LPCONNECTIONPOINT lpCPT;
if (SUCCEEDED(m_lpSelection->m_lpObject->QueryInterface(
IID_IConnectionPointContainer,(LPVOID FAR*)&lpCPC)))
{
if (SUCCEEDED(lpCPC->EnumConnectionPoints(&lpEnumCPTS)))
{
HRESULT hr = lpEnumCPTS->Next(1,&lpCPT,NULL); //GPF occurs here
if (NOERROR == hr)
{
AfxMessageBox(_T("Connection Point retrieved!"));
lpCPT->Release();
}
lpEnumCPTS->Release();
}
else
AfxMessageBox(_T("EnumConnectionPoints failed!"));
lpCPC->Release
}
else
AfxMessageBox(_T("QI for IConnectionPointContainer failed!"));
}
Additional query words: GPF
Keywords: kbbug kbfix kbnoupdate kblocalsvr kbvc500fix kbctrl KB131102