CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Threaded View

  1. #1
    Join Date
    Jan 2006
    Posts
    384

    STL Map : Uninitialized Memory Read

    Hi,

    This is regarding a problem encountered on executing code developed using VS2005 using C++ Standard Libraries.

    I have a member in a class of type std::map. The class definition is indicated below (There are some other class members which I am not indicating here so as to not occupy space)

    Code:
    class DataHolder
    {
    private :
    map<DWORD, MyClass *> m_MyMap;
    
    public :
    DataHolder()
    {
       m_MyMap.clear();
    }
    
    void MyMethod()
    {
            DWORD j = GetValue();
             map<DWORD,MyClass*>::iterator it = m_MyMap.begin();
             it = m_MyMap.find(j); //Rational Purifier indicated a problem in this line
             if (it == m_MyMap.end())
             {
                   printf("Data has not been found in the map");
             }
    
    }
    .
    .
    .
    .
    .
    .
    }
    When the above class is used in the execution of a program and the Rational Purifier tool is being used to analyze memory issues, the following error was indicated in the line marked above :

    "Uninitialized Memory Read "

    The next level of instructions displayed by the Rational Purifier editor shows the following

    Code:
        std::_Tree<class std::_Tmap_traits<unsigned long,class MyClass *,struct std::less<unsigned long>,class std::allocator<struct std::pair<unsigned long const ,class MyClass *> >,0> >::_Lbound(unsigned long const &)const  [c:\program files\microsoft visual studio 8\vc\include\xtree.:1174]
                    _Nodeptr _Wherenode = _Myhead;    // end() if search fails
            
                    while (!_Isnil(_Pnode))
         =>             if (_DEBUG_LT_PRED(this->comp, _Key(_Pnode), _Keyval))
                            _Pnode = _Right(_Pnode);    // descend right subtree
                        else
                            {    // _Pnode not less than _Keyval, remember it
    The problem is indicated in the line shown by "=> " in the snippet above.

    Can someone please provide some clues on why this is being indicated and what would be the possible solution.
    Last edited by humble_learner; February 5th, 2009 at 06:56 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured