I believe the following causes a memory access violation error as the false parameter (fcopy) causes the memory to be released for the CComBSTR:
CComBSTR myCComBSTR;
string strMyCComBSTR = string(_bstr_t(myCComBSTR, false));
However, I'm not quite sure why this is as the MSDN documentation says the following about fcopy:
If false, the bstr argument is attached to the new object without making a copy by calling SysAllocString.
My question is:
- Am I right in saying that this is a problem
- If so - why?
Thanks