class ATL_NO_VTABLE CMasterStore :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CMasterStore, &CLSID_MasterStore>,
public IDispatchImpl<IMasterStore, &IID_IMasterStore, &LIBID_PSLOGLib>
{
STDMETHODIMP CMasterStore::get_Description(BSTR *pVal)
{
*pVal = fbstrDescription.Copy();
return S_OK;
}
STDMETHODIMP CMasterStore::put_Description(BSTR newVal)
{
//SetDirty();
fbstrDescription = newVal;
return S_OK;
}
};
/* masterStore used below is a c# class as define here
public ref class **MasterStore**
{
public:
property short Code;
property String^ Description;*/
IMasterStore* _CurrentMasterStore; //interface
This line of code is causing a memory leak:
_CurrentMasterStore->put_Description(static_cast<BSTR>(Marshal::StringToBSTR(masterStore->Description).ToPointer()));
If I simply pass string as below, I don't see any memory leaks.
_CurrentMasterRecord->put_Description(L"Test memory leaks");
I am unable to find why it is leaking and how to fix it.
Any help is appreciated.
Thank you very much in advance!!