diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-04-08 17:47:22 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-04-08 17:47:22 -0700 |
commit | cea5c956486b8acae4bf5a23f0148d6b85d9acd3 (patch) | |
tree | 56fa09708b0fa235e8837cd1635fcfd33f3b2259 | |
parent | fb07c84eeaeda96eac369ff763dd9c1c5b5ee0fb (diff) | |
download | txr-cea5c956486b8acae4bf5a23f0148d6b85d9acd3.tar.gz txr-cea5c956486b8acae4bf5a23f0148d6b85d9acd3.tar.bz2 txr-cea5c956486b8acae4bf5a23f0148d6b85d9acd3.zip |
parser: fix few memory leaks in error recovery.
* parser.y (var, o_var): In a few error productions in which
we have a SYMTOK item, we should free the lexeme.
This doesn't solve all leaks: any time we have a parser
stack containing SYMTOK or TEXT items that belong to rules
that have not yet been reduced, and the parse job is aborted
due to errors, we leak those.
-rw-r--r-- | parser.y | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -818,13 +818,16 @@ var : SYMTOK { $$ = list(var_s, symhlpr($1, nil), nao); } | var_op SYMTOK { $$ = list(var_s, symhlpr($2, nil), $1, nao); } | var_op '{' SYMTOK '}' { $$ = list(var_s, symhlpr($3, nil), $1, nao); } | var_op '{' SYMTOK regex '}' { $$ = nil; + free($3); yyerr("longest match " "not useable with regex"); } | var_op '{' SYMTOK NUMBER '}' { $$ = nil; + free($3); yyerr("longest match " "not useable with " "fixed width match"); } | SYMTOK error { $$ = nil; + free($1); yybadtok(yychar, lit("variable spec")); } | var_op error { $$ = nil; yybadtok(yychar, lit("variable spec")); } @@ -856,6 +859,7 @@ o_var : SYMTOK { val expr = symhlpr($1, nil); val quasi_items = cons(quasi_var, nil); $$ = car(expand_quasi(quasi_items, nil)); } } | SYMTOK error { $$ = nil; + free($1); yybadtok(yychar, lit("variable spec")); } ; |