Boost C++ Libraries: Ticket #3474: Memory leak due to exception safety issue https://svn.boost.org/trac10/ticket/3474 <p> The following code fragment form file 'libs/filesystem/src/exception.cpp' may leak memory if an exception is thrown while assigning 'lpMsgBuf' to 'target': </p> <pre class="wiki">void system_message(system_error_type sys_err_code, std::string&amp; target) { LPVOID lpMsgBuf; ::FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, sys_err_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPSTR) &amp;lpMsgBuf, 0, NULL ); target += static_cast&lt;LPCSTR&gt;(lpMsgBuf); ::LocalFree( lpMsgBuf ); // free the buffer //... </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3474 Trac 1.4.3 lee@… Tue, 22 Sep 2009 11:06:26 GMT version, milestone changed https://svn.boost.org/trac10/ticket/3474#comment:1 https://svn.boost.org/trac10/ticket/3474#comment:1 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.40.0</span> → <span class="trac-field-new">Boost 1.35.0</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.41.0</span> → <span class="trac-field-new">To Be Determined</span> </li> </ul> Ticket Marshall Clow Mon, 14 Jun 2010 03:10:15 GMT component changed https://svn.boost.org/trac10/ticket/3474#comment:2 https://svn.boost.org/trac10/ticket/3474#comment:2 <ul> <li><strong>component</strong> <span class="trac-field-old">filesystem</span> → <span class="trac-field-new">system</span> </li> </ul> <p> As of boost 1.42.0, there are no calls to "FormatMessageA" in boost filesystem. There is similar code in the Boost.System library, though. Reassigning; Beman will squawk if I'm wrong. File: libs/system/src/error_code.cpp </p> <pre class="wiki"> std::string system_error_category::message( int ev ) const { # ifndef BOOST_NO_ANSI_APIS LPVOID lpMsgBuf; DWORD retval = ::FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, ev, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPSTR) &amp;lpMsgBuf, 0, NULL ); if (retval == 0) return std::string("Unknown error"); std::string str( static_cast&lt;LPCSTR&gt;(lpMsgBuf) ); ::LocalFree( lpMsgBuf ); // free the buffer # else // WinCE workaround </pre> Ticket Beman Dawes Tue, 29 Jun 2010 12:08:01 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3474#comment:3 https://svn.boost.org/trac10/ticket/3474#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Fixed. See changeset 63184 </p> <p> Thanks, </p> <p> --Beman </p> Ticket