From 2d1af99dc3ca1675f1e52af0765b76b335690eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jurko=20Gospodneti=C4=87?= Date: Sun, 24 Jun 2012 00:18:43 +0000 Subject: [PATCH] Boost Jam code cleanup - execnt.c module no longer double-frees its running commands table slot's action & target variables when reusing the same slot for multiple commands. [SVN r79043] --- v2/engine/execnt.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/v2/engine/execnt.c b/v2/engine/execnt.c index 092e19c48..327b86374 100644 --- a/v2/engine/execnt.c +++ b/v2/engine/execnt.c @@ -425,18 +425,25 @@ void exec_cmd /* Save the operation for exec_wait() to find. */ cmdtab[ slot ].func = func; cmdtab[ slot ].closure = closure; + /* No need to free action and target cmdtab[ slot ] members here as they + * have either never been explicitly constructed before (and are thus + * zero initialized) or have been freed when the previous command in the + * same slot has been cleaned up. + */ + assert( !cmdtab[ slot ].action->size ); + assert( !cmdtab[ slot ].action->value || cmdtab[ slot ].action->value == + cmdtab[ slot ].action->opt ); + assert( !cmdtab[ slot ].target->size ); + assert( !cmdtab[ slot ].target->value || cmdtab[ slot ].target->value == + cmdtab[ slot ].target->opt ); if ( action && target ) { - string_free( cmdtab[ slot ].action ); string_copy( cmdtab[ slot ].action, action ); - string_free( cmdtab[ slot ].target ); string_copy( cmdtab[ slot ].target, target ); } else { - string_free( cmdtab[ slot ].action ); string_new ( cmdtab[ slot ].action ); - string_free( cmdtab[ slot ].target ); string_new ( cmdtab[ slot ].target ); } string_copy( cmdtab[ slot ].command, pCommand_orig->value );