com - Converting CComBSTR to _bstr_t with fcopy as false -
I believe the following is a memory access violation error because the false parameter (fcopy) memory is ccmbrr:
CCMBRRI MERCOMBRIST; String strMyCComBSTR = string (_bstr_t (myCComBSTR, false));
However, I am not sure why MSDN document is said to have the following about the FCP:
If incorrect , Then bstr logic is attached
My question is:
- Am I correct by saying that this is a problem
- If so - why?
Thanks
Yes, this is a problem - both < Code> myCComBSTR and try to empty the temporary string because they both think that they believe it.
You can see, fcopy
value false
means "please do not duplicate the string body, just attach to the body that I give you Do " When the first row completes, you have ownership of myCComBSTR
string buffer and when the temporary object is created on the second line, then it is the same string buffer due to fcopy
Takes ownership of false
. Then temporarily destroys and releases the string buffer. Later myccomBSTR
will be deleted and will try to freeze the same string buffer - you run in the so-called double free which inspires undefined behavior. .
Comments
Post a Comment