]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: Fix use after free in lexer
authorQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 9 Aug 2016 19:30:40 +0000 (19:30 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 9 Aug 2016 19:30:40 +0000 (19:30 +0000)
Fix occasional bug where deleting flex's input
buffer happens earlier than flex expects

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
lib/command_parse.y

index 51c2331dc7987aa998433a27f2e490e272a26d72..bbdf11c6e84a06058450b5da5906babb7db2cf42 100644 (file)
@@ -152,7 +152,6 @@ start:
 {
   // tack on the command element
   terminate_graph (startnode, currnode, element);
-  cleanup();
 }
 | sentence_root cmd_token_seq '.' placeholder_token
 {
@@ -165,7 +164,6 @@ start:
 
   // tack on the command element
   terminate_graph (startnode, currnode, element);
-  cleanup();
 }
 
 sentence_root: WORD
@@ -394,7 +392,10 @@ parse_command_format(struct graph_node *start, struct cmd_element *cmd)
   yydebug = 0;
 
   // parse command into DFA
-  yyparse(cmd, start);
+  yyparse (cmd, start);
+
+  /* cleanup */
+  cleanup ();
 
   return start;
 }
@@ -416,7 +417,7 @@ cleanup()
   free (docstr_start);
 
   /* cleanup lexer */
-  cleanup_lexer();
+  cleanup_lexer ();
 
   /* clear state pointers */
   seqhead = NULL;