diff src/oct-parse.yy @ 11258:795c97ace02c

eliminate some possible memory leaks
author John W. Eaton <jwe@octave.org>
date Wed, 17 Nov 2010 02:40:43 -0500
parents 8d8e10058df6
children 2da532d0f41c
line wrap: on
line diff
--- a/src/oct-parse.yy	Tue Nov 16 03:39:23 2010 -0500
+++ b/src/oct-parse.yy	Wed Nov 17 02:40:43 2010 -0500
@@ -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.