mirror of
https://github.com/boostorg/build.git
synced 2026-02-21 02:52:12 +00:00
Fix memory leak for invoked function args.
If a function exits abnormally, for any reason, the passed in function frame args would leak. This change captures such early exits and cleans up the args for directly invoked functions. This clears up about 70% of current memory leaks.
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include "jam_strings.h"
|
||||
#include "variable.h"
|
||||
#include "output.h"
|
||||
#include "startup.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
@@ -146,7 +147,15 @@ LIST * evaluate_rule( RULE * rule, OBJECT * rulename, FRAME * frame )
|
||||
if ( rule->procedure )
|
||||
{
|
||||
auto function = b2::jam::make_unique_bare_jptr( rule->procedure, function_refer, function_free );
|
||||
result = function_run( function.get(), frame );
|
||||
try
|
||||
{
|
||||
result = function_run( function.get(), frame );
|
||||
}
|
||||
catch( b2::exit_result r )
|
||||
{
|
||||
lol_free( frame->args );
|
||||
b2::clean_exit( r );
|
||||
}
|
||||
}
|
||||
|
||||
if ( DEBUG_PROFILE && rule->procedure )
|
||||
|
||||
@@ -681,6 +681,8 @@ int main( int argc, char * * argv )
|
||||
catch ( b2::exit_result exit_code )
|
||||
{
|
||||
result = (int)exit_code;
|
||||
out_flush();
|
||||
err_flush();
|
||||
}
|
||||
|
||||
if ( DEBUG_PROFILE )
|
||||
|
||||
Reference in New Issue
Block a user