Skip to content

Commit

Permalink
Merge pull request #380 from eqvinox/realloc_size
Browse files Browse the repository at this point in the history
scanner: consistently +2 to realloc size for EOB
  • Loading branch information
westes authored Apr 25, 2024
2 parents bf23944 + dae428c commit 68eb578
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/c99-flex.skl
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]],
}
if ((yyscanner->yy_n_chars + number_to_move) > yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
int new_size = yyscanner->yy_n_chars + number_to_move + (yyscanner->yy_n_chars >> 1);
int new_size = yyscanner->yy_n_chars + number_to_move + (yyscanner->yy_n_chars >> 1) + 2;
yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf = (char *) yyrealloc(
(void *) yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf, (size_t) new_size, yyscanner );
if ( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top]->yy_ch_buf == NULL ) {
Expand Down
2 changes: 1 addition & 1 deletion src/cpp-flex.skl
Original file line number Diff line number Diff line change
Expand Up @@ -2534,7 +2534,7 @@ m4_ifdef( [[M4_MODE_USES_REJECT]],
}
if ((YY_G(yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
int new_size = YY_G(yy_n_chars) + number_to_move + (YY_G(yy_n_chars) >> 1);
int new_size = YY_G(yy_n_chars) + number_to_move + (YY_G(yy_n_chars) >> 1) + 2;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
(void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size M4_YY_CALL_LAST_ARG );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) {
Expand Down
2 changes: 1 addition & 1 deletion src/go-flex.skl
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ m4_ifdef([[M4_MODE_USES_REJECT]],
}
if ((yyscanner->yyNChars + numberToMove) > yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyInputBufSize) {
/* Extend the array by 50%, plus the number we really need. */
int newSize = yyscanner->yyNChars + numberToMove + (yyscanner->yyNChars >> 1);
int newSize = yyscanner->yyNChars + numberToMove + (yyscanner->yyNChars >> 1) + 2;
yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf = (char *) yyrealloc(
(void *) yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf, (size_t) newSize, yyscanner);
if (yyscanner->yyBufferStack[yyscanner->yyBufferStackTop]->yyChBuf == NULL) {
Expand Down

0 comments on commit 68eb578

Please sign in to comment.