summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsodabrew <sodabrew>2007-05-08 04:23:12 +0000
committersodabrew <sodabrew>2007-05-08 04:23:12 +0000
commitffb817496e3776642951bf1642449919fdce4c3c (patch)
treeb6cb3609ff291ed904c18b6faba305cf2bc841be
parent02caddec04b2f202d746eb1b13591cb536df63ef (diff)
downloadflex-ffb817496e3776642951bf1642449919fdce4c3c.tar.gz
Better checking after yyalloc/yyrealloc (resolves bug #1595967)
-rw-r--r--NEWS4
-rw-r--r--flex.skl16
2 files changed, 17 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 8978e62..677df96 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ See the file COPYING for copying conditions.
* after version 2.5.33
+** better checking after yyalloc/yyrealloc (resolves bug #1595967)
+
** flex now provides for a libfl_pic.a compiled with position
independent code. Particularly useful when including a flex scanner
in a shared library and with more recent versions of gcc. Thanks to the Debian project for the idea.
@@ -13,7 +15,7 @@ See the file COPYING for copying conditions.
header file.
** flex better escapes filenames with special characters in them
-(resolves#1623600)
+ (resolves bug #1623600)
** a memory leak was plugged(resolves bug #1601111)
diff --git a/flex.skl b/flex.skl
index 0a2f151..a6976c1 100644
--- a/flex.skl
+++ b/flex.skl
@@ -1262,6 +1262,8 @@ m4_ifdef( [[M4_YY_USES_REJECT]],
/* Create the reject buffer large enough to save one state per allowed character. */
if ( ! YY_G(yy_state_buf) )
YY_G(yy_state_buf) = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE M4_YY_CALL_LAST_ARG);
+ if ( ! YY_G(yy_state_buf) )
+ YY_FATAL_ERROR( "out of dynamic memory in yylex()" );
]])
if ( ! YY_G(yy_start) )
@@ -1686,6 +1688,8 @@ m4_ifdef( [[M4_YY_USES_REJECT]],
yy_size_t new_size = YY_G(yy_n_chars) + number_to_move + (YY_G(yy_n_chars) >> 1);
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
(void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, new_size M4_YY_CALL_LAST_ARG );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
}
YY_G(yy_n_chars) += number_to_move;
@@ -2221,6 +2225,9 @@ void yyFlexLexer::yyensure_buffer_stack(void)
YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
M4_YY_CALL_LAST_ARG);
+ if ( ! YY_G(yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
+
memset(YY_G(yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
@@ -2239,6 +2246,8 @@ void yyFlexLexer::yyensure_buffer_stack(void)
(YY_G(yy_buffer_stack),
num_to_alloc * sizeof(struct yy_buffer_state*)
M4_YY_CALL_LAST_ARG);
+ if ( ! YY_G(yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
/* zero only the new slots.*/
memset(YY_G(yy_buffer_stack) + YY_G(yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
@@ -2382,8 +2391,7 @@ m4_ifdef( [[M4_YY_NO_PUSH_STATE]],,
(void *) YY_G(yy_start_stack), new_size M4_YY_CALL_LAST_ARG );
if ( ! YY_G(yy_start_stack) )
- YY_FATAL_ERROR(
- "out of memory expanding start-condition stack" );
+ YY_FATAL_ERROR( "out of memory expanding start-condition stack" );
}
YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)++] = YY_START;
@@ -2989,6 +2997,8 @@ static int yytbl_hdr_read YYFARGS2(struct yytbl_hdr *, th, struct yytbl_reader *
/* Allocate enough space for the version and name fields */
bytes = th->th_hsize - 14;
th->th_version = (char *) yyalloc (bytes M4_YY_CALL_LAST_ARG);
+ if ( ! th->th_version )
+ YY_FATAL_ERROR( "out of dynamic memory in yytbl_hdr_read()" );
/* we read it all into th_version, and point th_name into that data */
if (fread (th->th_version, 1, bytes, rd->fp) != bytes){
@@ -3068,6 +3078,8 @@ static int yytbl_data_load YYFARGS2(struct yytbl_dmap *, dmap, struct yytbl_read
else
/* We point to the address of a pointer. */
*dmap->dm_arr = p = (void *) yyalloc (bytes M4_YY_CALL_LAST_ARG);
+ if ( ! p )
+ YY_FATAL_ERROR( "out of dynamic memory in yytbl_data_load()" );
}
/* If it's a struct, we read 2 integers to get one element */