mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-12 05:43:03 +00:00
Fix memory leaks in scanners generated by at least Flex 2.5.9 and
later. Reported by Paul Eggert in <http://lists.gnu.org/archive/html/bison-patches/2006-11/msg00014.html>. * src/flex-scanner.h (yylex_destroy): Define for Flex before 2.5.9. * src/scan-code.l (translate_action): Don't bother invoking yy_delete_buffer (YY_CURRENT_BUFFER) before creating the first buffer. (code_scanner_free): Instead of invoking yy_delete_buffer (YY_CURRENT_BUFFER) directly, invoke yylex_destroy, which frees more. * src/scan-gram.l (gram_scanner_free): Likewise. * src/scan-skel.l (scan_skel): Likewise.
This commit is contained in:
@@ -380,8 +380,6 @@ translate_action (int sc_context, symbol_list *rule, char const *a, location l)
|
||||
if (!initialized)
|
||||
{
|
||||
obstack_init (&obstack_for_string);
|
||||
/* The initial buffer, never used. */
|
||||
yy_delete_buffer (YY_CURRENT_BUFFER);
|
||||
yy_flex_debug = 0;
|
||||
initialized = true;
|
||||
}
|
||||
@@ -422,5 +420,5 @@ code_scanner_free (void)
|
||||
{
|
||||
obstack_free (&obstack_for_string, 0);
|
||||
/* Reclaim Flex's buffers. */
|
||||
yy_delete_buffer (YY_CURRENT_BUFFER);
|
||||
yylex_destroy ();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user