mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-22 10:43:02 +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:
14
ChangeLog
14
ChangeLog
@@ -1,3 +1,17 @@
|
|||||||
|
2006-11-10 Joel E. Denny <jdenny@ces.clemson.edu>
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
2006-11-09 Joel E. Denny <jdenny@ces.clemson.edu>
|
2006-11-09 Joel E. Denny <jdenny@ces.clemson.edu>
|
||||||
|
|
||||||
* src/files.c (tr): Change return type to void.
|
* src/files.c (tr): Change return type to void.
|
||||||
|
|||||||
@@ -50,6 +50,19 @@ int FLEX_PREFIX (lex_destroy) (void);
|
|||||||
# define yytext FLEX_PREFIX (text)
|
# define yytext FLEX_PREFIX (text)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Non-reentrant scanners generated by Flex 2.5.9 and later (and some earlier
|
||||||
|
versions according to the Flex manual) leak memory if yylex_destroy is not
|
||||||
|
invoked. However, yylex_destroy is not defined before Flex 2.5.9, so give
|
||||||
|
an implementation here that at least appears to work with Flex 2.5.4. */
|
||||||
|
#if !defined(YY_FLEX_MAJOR_VERSION) || YY_FLEX_MAJOR_VERSION < 2 \
|
||||||
|
|| (YY_FLEX_MAJOR_VERSION == 2 \
|
||||||
|
&& (!defined(YY_FLEX_MINOR_VERSION) || YY_FLEX_MINOR_VERSION < 5 \
|
||||||
|
|| (YY_FLEX_MINOR_VERSION == 5 \
|
||||||
|
&& (!defined(YY_FLEX_SUBMINOR_VERSION) \
|
||||||
|
|| YY_FLEX_SUBMINOR_VERSION < 9))))
|
||||||
|
# define yylex_destroy() yy_delete_buffer (YY_CURRENT_BUFFER)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* OBSTACK_FOR_STRING -- Used to store all the characters that we need to
|
/* OBSTACK_FOR_STRING -- Used to store all the characters that we need to
|
||||||
keep (to construct ID, STRINGS etc.). Use the following macros to
|
keep (to construct ID, STRINGS etc.). Use the following macros to
|
||||||
use it.
|
use it.
|
||||||
|
|||||||
@@ -380,8 +380,6 @@ translate_action (int sc_context, symbol_list *rule, char const *a, location l)
|
|||||||
if (!initialized)
|
if (!initialized)
|
||||||
{
|
{
|
||||||
obstack_init (&obstack_for_string);
|
obstack_init (&obstack_for_string);
|
||||||
/* The initial buffer, never used. */
|
|
||||||
yy_delete_buffer (YY_CURRENT_BUFFER);
|
|
||||||
yy_flex_debug = 0;
|
yy_flex_debug = 0;
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
@@ -422,5 +420,5 @@ code_scanner_free (void)
|
|||||||
{
|
{
|
||||||
obstack_free (&obstack_for_string, 0);
|
obstack_free (&obstack_for_string, 0);
|
||||||
/* Reclaim Flex's buffers. */
|
/* Reclaim Flex's buffers. */
|
||||||
yy_delete_buffer (YY_CURRENT_BUFFER);
|
yylex_destroy ();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -800,5 +800,5 @@ gram_scanner_free (void)
|
|||||||
{
|
{
|
||||||
obstack_free (&obstack_for_string, 0);
|
obstack_free (&obstack_for_string, 0);
|
||||||
/* Reclaim Flex's buffers. */
|
/* Reclaim Flex's buffers. */
|
||||||
yy_delete_buffer (YY_CURRENT_BUFFER);
|
yylex_destroy ();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,5 +121,5 @@ scan_skel (FILE *in)
|
|||||||
skel__flex_debug = trace_flag & trace_skeleton;
|
skel__flex_debug = trace_flag & trace_skeleton;
|
||||||
skel_lex ();
|
skel_lex ();
|
||||||
/* Reclaim Flex's buffers. */
|
/* Reclaim Flex's buffers. */
|
||||||
yy_delete_buffer (YY_CURRENT_BUFFER);
|
yylex_destroy ();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user