Bug in CComBSTR::ToLower and ::ToUpper ???
-
In the two places I have boldened below, should the code be checking for 'b' to be NULL instead of psz, after the call to T2BSTR ??? :~
HRESULT ToLower() { USES_CONVERSION; if (m_str != NULL) { LPTSTR psz = CharLower(OLE2T(m_str)); if (psz == NULL) return E_OUTOFMEMORY; BSTR b = T2BSTR(psz); **if (psz == NULL)** return E_OUTOFMEMORY; SysFreeString(m_str); m_str = b; } return S_OK; } HRESULT ToUpper() { USES_CONVERSION; if (m_str != NULL) { LPTSTR psz = CharUpper(OLE2T(m_str)); if (psz == NULL) return E_OUTOFMEMORY; BSTR b = T2BSTR(psz); **if (psz == NULL)** return E_OUTOFMEMORY; SysFreeString(m_str); m_str = b; } return S_OK; }
Any sufficiently gross incompetence is nearly indistinguishable from malice.
-
In the two places I have boldened below, should the code be checking for 'b' to be NULL instead of psz, after the call to T2BSTR ??? :~
HRESULT ToLower() { USES_CONVERSION; if (m_str != NULL) { LPTSTR psz = CharLower(OLE2T(m_str)); if (psz == NULL) return E_OUTOFMEMORY; BSTR b = T2BSTR(psz); **if (psz == NULL)** return E_OUTOFMEMORY; SysFreeString(m_str); m_str = b; } return S_OK; } HRESULT ToUpper() { USES_CONVERSION; if (m_str != NULL) { LPTSTR psz = CharUpper(OLE2T(m_str)); if (psz == NULL) return E_OUTOFMEMORY; BSTR b = T2BSTR(psz); **if (psz == NULL)** return E_OUTOFMEMORY; SysFreeString(m_str); m_str = b; } return S_OK; }
Any sufficiently gross incompetence is nearly indistinguishable from malice.
Where you get this code from ? With VS2005 its different from what you have posted. If at all there is code like this, then there is is bug. It should be checked with 'b'.
Prasad Notifier using ATL | Operator new[],delete[][^]
-
Where you get this code from ? With VS2005 its different from what you have posted. If at all there is code like this, then there is is bug. It should be checked with 'b'.
Prasad Notifier using ATL | Operator new[],delete[][^]
This code was lifted directly from the source for one of Microsoft's ATL libraries. In this case, Visual Studio 6.0 - ...\VC98\ATL\Include\AtlBase.H The function does not appear to be a problem in VS 2003 - it uses different algorithms - handling Unicode and other issues - see AtlComCli.H.
Any sufficiently gross incompetence is nearly indistinguishable from malice.
-
This code was lifted directly from the source for one of Microsoft's ATL libraries. In this case, Visual Studio 6.0 - ...\VC98\ATL\Include\AtlBase.H The function does not appear to be a problem in VS 2003 - it uses different algorithms - handling Unicode and other issues - see AtlComCli.H.
Any sufficiently gross incompetence is nearly indistinguishable from malice.
Yes, Now I can see it. Is it is definitely a bug(Now we should say 'was', as VC 6 is no longer supported). I wonder,How it goes unnoticed for such length of time. May be, nobody is supposed to see implementation.
Prasad Notifier using ATL | Operator new[],delete[][^]