Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. Bug in CComBSTR::ToLower and ::ToUpper ???

Bug in CComBSTR::ToLower and ::ToUpper ???

Scheduled Pinned Locked Moved ATL / WTL / STL
helpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Blake Miller
    wrote on last edited by
    #1

    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.

    P 1 Reply Last reply
    0
    • B Blake Miller

      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.

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      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[][^]

      B 1 Reply Last reply
      0
      • P prasad_som

        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[][^]

        B Offline
        B Offline
        Blake Miller
        wrote on last edited by
        #3

        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.

        P 1 Reply Last reply
        0
        • B Blake Miller

          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.

          P Offline
          P Offline
          prasad_som
          wrote on last edited by
          #4

          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[][^]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups