Bad Ptr in COM

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dudisreena
    New Member
    • Feb 2012
    • 2

    #1

    Bad Ptr in COM

    When I am resizing my vector in COM like in the below code.
    m_vecDBInfo[iDb].bmsDim.resize( sDimCount);//added by ds

    It internally routing to vector class of mfc(c:\program files (x86)\microsoft visual studio 8\vc\include\ve ctor) while debugging like in the below code.

    _Ty _Tmp = _Val; // in case _Val is in sequence

    where _val is my vector.
    so here after executing the above statement i can see Bat Ptr for the elements of vector like
    _Tmp = {m_strLen=0 m_bstr=0x002c68 88cccccccc <Bad Ptr> m_count=0 ...}
    m_strLen = 0
    m_bstr = 0x002c6888ccccc ccc <Bad Ptr>
    m_count = 0
    m_pBits = 0xcccccccc00000 000 <Bad Ptr>

    where m_strLen ,m_bstr(of type BSTR),m_count ,m_pBits(of type unsigned char*) are elements of vector .

    Can Any one pls guide me why it says "Bad Ptr" for the element m_bstr and m_pBits ?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Bad Ptr in Visual Studio just means an uninitialized pointer.

    Visual Studio initializes all pointers with a known garbage value. Whenever Visual Studio sees that value it displays "Bad Ptr".

    You can put your own garbage value in there and the "Bad Ptr" will disappear but your program will still crash. VS is just trying to identify for you all pointers you have not initialized.

    Comment

    Working...