summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorExplorer09 <explorer09@gmail.com>2019-11-04 11:05:39 +0800
committerExplorer09 <explorer09@gmail.com>2021-06-07 09:30:46 +0800
commit60c4453b6ac1e29dbe039216ed948108eb9c6701 (patch)
treec7537341849ab07d41f3d4a7bb4f6f5f495f2353 /src
parentc26cd7bc13b30fcfafe394330f3fe70672d9e47a (diff)
downloadflex-git-60c4453b6ac1e29dbe039216ed948108eb9c6701.tar.gz
scanner: Fix compiler confusion in yy_init_buffer()
When complied with 'gcc -O3', the yy_init_buffer call can confuse gcc, thinking the 'b' pointer may be NULL. (gcc would warn that if '-Wnull-dereference' is used). Fix the confusion by never pass a NULL constant to the function. Fixes: #377 Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/c99-flex.skl2
-rw-r--r--src/cpp-flex.skl2
-rw-r--r--src/go-flex.skl2
3 files changed, 3 insertions, 3 deletions
diff --git a/src/c99-flex.skl b/src/c99-flex.skl
index 08b143a..1e04afe 100644
--- a/src/c99-flex.skl
+++ b/src/c99-flex.skl
@@ -854,7 +854,7 @@ void yyrestart(FILE * input_file, yyscan_t yyscanner)
yy_create_buffer( yyscanner->yyin_r, YY_BUF_SIZE, yyscanner);
}
- yy_init_buffer( yy_current_buffer(yyscanner), input_file, yyscanner);
+ yy_init_buffer( yyscanner->yy_buffer_stack[yyscanner->yy_buffer_stack_top], input_file, yyscanner);
yy_load_buffer_state( yyscanner );
}
diff --git a/src/cpp-flex.skl b/src/cpp-flex.skl
index e33265d..1db0446 100644
--- a/src/cpp-flex.skl
+++ b/src/cpp-flex.skl
@@ -2831,7 +2831,7 @@ void yyFlexLexer::yyrestart( std::istream& input_file )
yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG);
}
- yy_init_buffer( yy_current_buffer(), input_file M4_YY_CALL_LAST_ARG);
+ yy_init_buffer( YY_CURRENT_BUFFER_LVALUE, input_file M4_YY_CALL_LAST_ARG);
yy_load_buffer_state( M4_YY_CALL_ONLY_ARG );
}
diff --git a/src/go-flex.skl b/src/go-flex.skl
index 39b3cd1..f2807dd 100644
--- a/src/go-flex.skl
+++ b/src/go-flex.skl
@@ -763,7 +763,7 @@ void yyrestart(FILE * input_file, FlexLexer *yyscanner)
yy_create_buffer(yyscanner->yyin, flexInputBufferSize, yyscanner);
}
- yy_init_buffer(yy_current_buffer(yyscanner), input_file, yyscanner);
+ yy_init_buffer(yyscanner->yyBufferStack[yyscanner->yyBufferStackTop], input_file, yyscanner);
yy_load_buffer_state(yyscanner);
}