# HG changeset patch # User John W. Eaton # Date 1381341192 14400 # Node ID 77eff9c6fb09e3197677f4725966383415c0daa9 # Parent 9abb1422d60b9a12d1d6841c7ff9a0d21d783e89 avoid memory leak when parsing function files (bug #40218) * oct-parse.in.yy (file): Delete opt_list if parsing a function file. diff -r 9abb1422d60b -r 77eff9c6fb09 libinterp/parse-tree/oct-parse.in.yy --- a/libinterp/parse-tree/oct-parse.in.yy Wed Oct 09 17:33:50 2013 +0200 +++ b/libinterp/parse-tree/oct-parse.in.yy Wed Oct 09 13:53:12 2013 -0400 @@ -1126,7 +1126,17 @@ file : INPUT_FILE opt_nl opt_list END_OF_INPUT { - if (! lexer.reading_fcn_file) + if (lexer.reading_fcn_file) + { + // Delete the dummy statement_list we created + // after parsing the function. Any function + // definitions found in the file have already + // been stored in the symbol table or in + // octave_base_parser::primary_fcn_ptr. + + delete $3; + } + else { tree_statement *end_of_script = parser.make_end ("endscript", true,