Error found by Dr.Memory: don't know how to fix it

1.1k Views Asked by At

Is there anything I can do about such error found by dr. Memory?

Error #xxx: INVALID HEAP ARGUMENT: allocated with operator new, freed with free
std::_DebugHeapDelete<std::locale>
    ??:0
std::ios_base::_Ios_base_dtor
    ??:0
std::ios_base::~ios_base
    ??:0
std::basic_ios<char,std::char_traits<char> >::~basic_ios<char,std::char_traits<char> >
    ??:0
std::basic_stringstream<char,std::char_traits<char>,std::allocator<char> >::`vbase destructor'
    ??:0
some_namespace::some_function()
    some_source.cpp(60):

Note: memory was allocated here:
Note: std::ios_base::_Init
    ??:0
Note: std::basic_ios<char,std::char_traits<char> >::init
    ??:0
Note: std::basic_istream<char,std::char_traits<char> >::basic_istream<char,std::char_traits<char> >
    ??:0
Note: std::basic_iostream<char,std::char_traits<char> >::basic_iostream<char,std::char_traits<char> >
    ??:0
Note: std::basic_stringstream<char,std::char_traits<char>,std::allocator<char> >::basic_stringstream<char,std::char_traits<char>,std::allocator<char> >
    ??:0
Note: some_namespace::some_function()
Note:     some_source.cpp(30):

Where code looks like this (lines added for convenience):

string some_function( int i, int j, int k )
{
30:  stringstream ss;
(...)
     std::string res = ss.str();
(...)
60:  return res;    
}

The compiler is VisualStudio 2008 sp1, language native c++. Of course, after changing .rdbuf()->str() to simply .str() - nothing changed, error still exists.

1

There are 1 best solutions below

0
On

I think that this is a bug in Dr. Memory,

as it says "INVALID HEAP ARGUMENT to free 0x0bdd3048" in following code

template<typename CharType>
class MessageBuilder
{
   (...)
          {
            std::basic_ostringstream<CharType> ss;
            ss << msg;
            msg_ += ss.str();
-->       }
};