1

我正在查看泄漏内存。我正在使用 Valgrind,但我遇到了一些错误,例如:

Invalid read of size 1
==6643==    at 0x4026CC4: strlen (mc_replace_strmem.c:282)
==6643==    by 0x40D42DA: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)
==6643==    by 0x804B8AB: main
==6643==  Address 0x441f895 is 13 bytes inside a block of size 45 free'd
==6643==    at 0x4025504: operator delete(void*) (vg_replace_malloc.c:387)
==6643==    by 0x40D1ACC: std::string::_Rep::_M_destroy(std::allocator<char> const&) 
==6643==    by 0x40D1B8B: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() 
==6643==    by 0x804CE6A: TiXmlNode::~TiXmlNode() 
==6643==    by 0x80B6241: TiXmlText::~TiXmlText() 
==6643==    by 0x804D0B0: TiXmlNode::Clear()
==6643==    by 0x804E13E: TiXmlElement::ClearThis() 

代码是:

TiXmlHandle handle(&doc);


TiXmlElement* section,*pRoot,*pParam,*section1,*section2;

pRoot=doc.FirstChildElement("xml");


 pParam=pRoot->FirstChildElement("Data");

while (pParam)
{

section = pParam->FirstChildElement("Name");
    if (section)
   {

    const char* str= section->GetText();

    long long int v;
    sscanf(str, "%lld", &v);


    }

欣赏。谢谢

4

0 回答 0