Careful with & operator on CComBSTR variables.

Be careful when using the & operator on a CComBSTR variable. If this variable is not empty, using the & operator on it to point it to a new BSTR will lead to a memory leak.

For instance,

if you have a variable bsz1

declared and initialized as:

CComBSTR bsz1("HiWorld");

the member BSTR is allocated by issuing a call to SysAllocString. If you use somewhere after that in your code (&bsz1), you will cause a memory leak.

You can call bsz1.empty() before you use &bsz1 to prevent from the memory leak.

Cheers.

Elyasse