
Invalid Address - RtlSizeHeap caused by function
I've got the function below which shows the Data Link dialog box in an
MMC snapin. Everything works
fine. However in debug mode, when the function returns, we always get
the error:
Invalid Address specified to RtlSizeHeap( 00080000, 000E0574 )
in the VC6.0 debug window. A dialog which also says
User Breakpoint called from code at 0x77f7f570. Also appears. We
originally had WCHAR buffers, but
thought that changing these to CComBSTR would automatically release
any memory within the buffers.
Code follows below:
CComBSTR GetDataSource(LPOLESTR lpbstrConn)
{
CComBSTR bstr;
IUnknown * pUnkDataSource = NULL;
IDataInitialize *pIDataInitialize = NULL;
IDBPromptInitialize * pIDBPromptInitialize = NULL;
CoCreateInstance( CLSID_DataLinks,
NULL,
CLSCTX_INPROC_SERVER,
IID_IDataInitialize,
(void**)&pIDataInitialize
);
try
{
pIDataInitialize->GetDataSource( NULL,
CLSCTX_INPROC_SERVER,
lpbstrConn,
IID_IUnknown,
(IUnknown**)&pUnkDataSource
);
}
catch(...)
{
}
CoCreateInstance( CLSID_DataLinks,
NULL,
CLSCTX_INPROC_SERVER,
IID_IDBPromptInitialize,
(void**)&pIDBPromptInitialize
);
pIDBPromptInitialize->PromptDataSource(
NULL,
GetDesktopWindow(),
DBPROMPTOPTIONS_PROPERTYSHEET,
0,
NULL,
NULL,
IID_IUnknown,
(IUnknown**)&pUnkDataSource
);
pIDataInitialize->GetInitializationString(pUnkDataSource,false,
&bstr);
if (pIDBPromptInitialize)
pIDBPromptInitialize->Release();
if (pIDataInitialize)
pIDataInitialize->Release();
if (pUnkDataSource)
pUnkDataSource->Release();
return _T("");
Quote:
};