c++ - CComBSTR memory leak and assignment -
i debugging old c++/com code without having much com experience.
is right code below leak (the empty string lost)? is right , safe assign value of ctext myccombstr in way?code:
tchar ctext[max_path] = {0}; ccombstr myccombstr(l""); functionthatfillsdataintextbuffer(&ctext[0]); myccombstr = ctext; // empty string leaked?
when assign array ccombstr free holding, can in header see how things implemented:
ccombstr& operator=(_in_opt_z_ lpcolestr psrc) { if (psrc != m_str) { ::sysfreestring(m_str); if (psrc != null) { m_str = ::sysallocstring(psrc); if (!*this) { atlthrow(e_outofmemory); } } else { m_str = null; } } homecoming *this; }
c++ memory-leaks com
No comments:
Post a Comment