# HG changeset patch # User John W. Eaton # Date 1289979643 18000 # Node ID 795c97ace02c1215a62e88ab812769fadf2f1d29 # Parent 8d4c57258523f290191539cc5e5420e656ab65e9 eliminate some possible memory leaks diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2010-11-17 John W. Eaton + + * oct-parse.yy (parse_fcn_file): Protect and set global_command + to 0 before calling yyparse. + * toplev.cc (main_loop): Likewise. + + * oct-parse.yy (eval_string): Set global_command to 0 after + protecting it and before calling yyparse. + * input.cc (get_debug_input): Likewise. + 2010-11-14 Michael Goffioul * graphics.h.in (graphics_object::get_ancestor): New method. diff --git a/src/input.cc b/src/input.cc --- a/src/input.cc +++ b/src/input.cc @@ -737,6 +737,8 @@ // Save current value of global_command. frame.protect_var (global_command); + global_command = 0; + // Do this with an unwind-protect cleanup function so that the // forced variables will be unmarked in the event of an interrupt. symbol_table::scope_id scope = symbol_table::top_scope (); diff --git a/src/oct-parse.yy b/src/oct-parse.yy --- a/src/oct-parse.yy +++ b/src/oct-parse.yy @@ -546,9 +546,7 @@ YYACCEPT; } | function_file - { - YYACCEPT; - } + { YYACCEPT; } | simple_list parse_error { ABORT_PARSE; } | parse_error @@ -3576,8 +3574,14 @@ lexer_flags.parsing_class_method = ! dispatch_type.empty (); + frame.protect_var (global_command); + + global_command = 0; + int status = yyparse (); + delete global_command; + fcn_ptr = primary_fcn_ptr; if (reading_fcn_file && endfunction_found && max_function_depth > 1) @@ -4318,6 +4322,8 @@ frame.protect_var (global_command); + global_command = 0; + // Do this with an unwind-protect cleanup function so that the // forced variables will be unmarked in the event of an // interrupt. diff --git a/src/toplev.cc b/src/toplev.cc --- a/src/toplev.cc +++ b/src/toplev.cc @@ -560,6 +560,10 @@ symbol_table::scope_id scope = symbol_table::top_scope (); frame.add_fcn (symbol_table::unmark_forced_variables, scope); + frame.protect_var (global_command); + + global_command = 0; + // This is the same as yyparse in parse.y. retval = octave_parse ();