mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 00:33: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:
@@ -50,6 +50,19 @@ int FLEX_PREFIX (lex_destroy) (void);
|
||||
# define yytext FLEX_PREFIX (text)
|
||||
#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
|
||||
keep (to construct ID, STRINGS etc.). Use the following macros to
|
||||
use it.
|
||||
|
||||
Reference in New Issue
Block a user